Skip to content

CAMEL-24342: camel-google-storage - fix wrong blob metadata and missing object handling - #25338

Merged
oscerd merged 2 commits into
apache:mainfrom
oscerd:fix/CAMEL-24342
Aug 6, 2026
Merged

CAMEL-24342: camel-google-storage - fix wrong blob metadata and missing object handling#25338
oscerd merged 2 commits into
apache:mainfrom
oscerd:fix/CAMEL-24342

Conversation

@oscerd

@oscerd oscerd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Three defects in camel-google-storage, all covered by new tests.

1. Uploads stored the content type in two other blob fields. processFile read the
Content-Encoding and Cache-Control entries from the metadata map but then passed the content
type
variable to the builder:

String ce = objectMetadata.remove("Content-Encoding");
if (ce != null) { builder.setContentEncoding(ct); }   // ct == Content-Type
...
String cc = objectMetadata.remove("Cache-Control");
if (cc != null) { builder.setCacheControl(ct); }      // ct == Content-Type

So an upload sending those headers ended up with the content type in both fields — or null, when
no Content-Type header was sent at all.

2. getObject NPE'd on a missing object. storage.get(BlobId) returns null when the object
is not there, and the result was dereferenced straight away. It now fails with a message naming the
object and the bucket.

3. The consumer NPE'd on every poll when the configured objectName was missing. Same null
blob, this time handed to createExchange. The poll now logs and yields no exchange. That path also
never called forceConsumerAsReady(), so the consumer health check stayed not-ready when
objectName was configured; it is now marked ready as soon as the storage client answers, like on
the list path.

Two cleanups in the touched file: the else branch in createDownloadLink was unreachable (the
header lookup already supplies the 300000L default), and the java.util.* wildcard import is
replaced with explicit ones.

Not changed: the audit that produced this issue also flagged that the objectName endpoint
option wins over the CamelGoogleCloudStorageObjectName header. That is deliberate — CAMEL-20998
made it so, because a consumer in the same route sets that header and would otherwise hijack the
producer destination. Only a comment recording the reason was added, and the item was withdrawn in a
comment on the JIRA issue.

Claude Code on behalf of oscerd

🤖 Generated with Claude Code

…ng object handling

processFile assigned the content type to the Content-Encoding and Cache-Control
fields of the blob, so an upload carrying those headers stored the content type
in them, or null when no content type was sent.

getObject dereferenced the blob returned by the storage client without checking
it, so asking for an object that is not in the bucket failed with a
NullPointerException instead of naming the missing object. The consumer had the
same problem when polling a configured objectName that does not exist: the poll
threw on every cycle, and that path never marked the consumer as ready.

Also drops the unreachable else branch in createDownloadLink (the header lookup
already supplies the default) and replaces the java.util wildcard import.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd
oscerd requested review from davsclaus and gnodet August 5, 2026 06:29
@oscerd oscerd added the bug Something isn't working label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-google/camel-google-storage

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-google-storage
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Google :: Storage
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent bug-fix PR that addresses three real issues:

  1. Copy-paste variable error in blob metadata handling — contentEncoding and cacheControl were being set to the content-type value instead of their respective header values. The root cause traces back to CAMEL-18300 (2022), where ct was used instead of ce/cc for two of the four metadata fields. CAMEL-22273 fixed contentDisposition last year; this PR completes the fix for the remaining two.

  2. NPE path when a configured objectName points to a missing object — now correctly throws a descriptive exception with the object name.

  3. createDownloadLink dead code cleanupgetHeader(key, defaultValue, type) with a non-null default of 300000L can never return null, so the else branch was unreachable. Simplifying to primitive long is the right call.

Test coverage is good, with two dedicated test classes covering all three fixes.

Minor convention note: ProducerBlobMetadataTest uses public class/method visibility and JUnit assertions (assertEquals, assertNotNull), while the other new test file (GoogleCloudStorageConsumerMissingObjectTest) correctly uses package-private visibility and AssertJ. Per project conventions, new test code should prefer package-private visibility and AssertJ assertions. Not blocking — just a consistency note.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @gnodet

…(package-private + AssertJ)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd

oscerd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 5ac3ff6ProducerBlobMetadataTest is now package-private with package-private test methods and uses AssertJ (assertThat(...)), matching GoogleCloudStorageConsumerMissingObjectTest. Thanks @gnodet.

@oscerd oscerd self-assigned this Aug 6, 2026
@oscerd oscerd added this to the 4.22.0 milestone Aug 6, 2026
@oscerd
oscerd merged commit c3e964b into apache:main Aug 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants