Skip to content

CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects - #25326

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

CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects#25326
oscerd merged 2 commits into
apache:mainfrom
oscerd:fix/CAMEL-24341

Conversation

@oscerd

@oscerd oscerd commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes the defects found in PubsubReloadTriggerTask (the gcp-secret-refresh period task):

  • The GCP task read the AWS vault configuration. secrets was populated from
    getVaultConfiguration().aws().getSecrets(), so the documented camel.vault.gcp.secrets option was
    never honoured, and configuring only the GCP property made doStart fail with
    "Secrets must be configured on GCP vault configuration". The vault lookup now reads the GCP
    configuration, and was moved ahead of the properties-function auto-detection (both are plain reads,
    the "secrets must be configured" check still runs after both).
  • triggerReloading was receiver state and never reset. After the first matching secret event every
    subsequent message on the subscription triggered another CamelContext reload. It is now a local
    variable, like in the AWS equivalent (CloudTrailReloadTriggerTask).
  • The subscriber was started on every period. run() is invoked every camel.vault.gcp.refreshPeriod
    (default 30s) and a Google ApiService can only be started while it is NEW, so every tick after the
    first failed with an IllegalStateException. The subscriber is now started once.
  • Foreign messages killed the receiver. eventType/secretId were dereferenced without a null check,
    so any message on the subscription without those attributes threw and was redelivered indefinitely.

Also in this PR: the javadoc of setReloadEnabled said "on AWS secret updated", the properties function
javadoc documented camel.vault.aws.* instead of camel.vault.gcp.*, and the secret sub-key lookup
allocated an ObjectMapper per call.

PubsubReloadTriggerTask had no test coverage at all; this adds PubsubReloadTriggerTaskTest, with one
test per defect above.

🤖 Generated with Claude Code

… defects

The GCP secret refresh task read the AWS vault configuration, so
camel.vault.gcp.secrets was never honoured. It also kept triggerReloading
as receiver state, so every message following a matching secret event
triggered another CamelContext reload, restarted the subscriber on every
period (a Google ApiService can only be started while it is NEW), and
dereferenced the secretId/eventType attributes without a null check, so a
message published on the subscription by anything else failed and was
redelivered forever.

Also aligns the javadoc of the task and of the properties function with GCP
and reuses a single ObjectMapper for secret sub-key lookups.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>

@davsclaus davsclaus 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.

All four bug fixes are correct and well-diagnosed:

  • GCP→AWS secrets readaws().getSecrets() was clearly wrong; confirmed by comparing with the AWS CloudTrailReloadTriggerTask which correctly reads aws().getSecrets() for its own config.
  • triggerReloading as local variable — matches the pattern already used in CloudTrailReloadTriggerTask (line 271). The old field-level flag caused every subsequent message to trigger a reload after the first match.
  • Subscriber started onceApiService.State.NEW check is the correct guard; a Google ApiService throws IllegalStateException if started again after RUNNING.
  • Null-safe attributes — constant-first equalsIgnoreCase plus explicit secretId != null prevents NPE on foreign messages.

Static ObjectMapper in GoogleSecretManagerPropertiesFunction is thread-safe for readTree() — good cleanup.

Minor convention notes (non-blocking):

  • Test class and methods use public — JUnit 5 convention in this project is package-private (no modifier).
  • Tests use JUnit assertions (assertEquals, assertTrue, etc.) — project prefers AssertJ (assertThat(...)).

These are small style items and don't block the PR.

⚠️ Note: CI checks are still pending at time of review.

This review was generated by an AI agent (Claude Code on behalf of davsclaus) and may contain inaccuracies. Please verify all suggestions before applying.

@github-actions

github-actions Bot commented Aug 4, 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.

…tions

Per davsclaus's non-blocking note, PubsubReloadTriggerTaskTest now uses
package-private class/@test visibility and AssertJ assertions (assertThat,
assertThatThrownBy, assertThatCode(...).doesNotThrowAnyException()). The
interface-override methods (onReload/ack/nack) stay public since they override
public API. Adds a test-scoped assertj-core dependency, not previously on the
module's test classpath.

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

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-google/camel-google-secret-manager

🔬 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-secret-manager
  • 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 :: Secret Manager
  • 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

@oscerd oscerd added the bug Something isn't working label Aug 4, 2026
@oscerd oscerd self-assigned this Aug 4, 2026
@oscerd oscerd added this to the 4.22.0 milestone Aug 4, 2026
@oscerd
oscerd merged commit a1700b1 into apache:main Aug 4, 2026
5 checks passed
oscerd added a commit that referenced this pull request Aug 5, 2026
…x GCP vault refresh task defects (#25339)

CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects (#25326)

* CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects

The GCP secret refresh task read the AWS vault configuration, so
camel.vault.gcp.secrets was never honoured. It also kept triggerReloading
as receiver state, so every message following a matching secret event
triggered another CamelContext reload, restarted the subscriber on every
period (a Google ApiService can only be started while it is NEW), and
dereferenced the secretId/eventType attributes without a null check, so a
message published on the subscription by anything else failed and was
redelivered forever.

Also aligns the javadoc of the task and of the properties function with GCP
and reuses a single ObjectMapper for secret sub-key lookups.



* CAMEL-24341: address review - AssertJ and package-private test conventions

Per davsclaus's non-blocking note, PubsubReloadTriggerTaskTest now uses
package-private class/@test visibility and AssertJ assertions (assertThat,
assertThatThrownBy, assertThatCode(...).doesNotThrowAnyException()). The
interface-override methods (onReload/ack/nack) stay public since they override
public API. Adds a test-scoped assertj-core dependency, not previously on the
module's test classpath.




---------

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
oscerd added a commit that referenced this pull request Aug 5, 2026
…x GCP vault refresh task defects (#25340)

CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects (#25326)

* CAMEL-24341: camel-google-secret-manager - fix GCP vault refresh task defects

The GCP secret refresh task read the AWS vault configuration, so
camel.vault.gcp.secrets was never honoured. It also kept triggerReloading
as receiver state, so every message following a matching secret event
triggered another CamelContext reload, restarted the subscriber on every
period (a Google ApiService can only be started while it is NEW), and
dereferenced the secretId/eventType attributes without a null check, so a
message published on the subscription by anything else failed and was
redelivered forever.

Also aligns the javadoc of the task and of the properties function with GCP
and reuses a single ObjectMapper for secret sub-key lookups.



* CAMEL-24341: address review - AssertJ and package-private test conventions

Per davsclaus's non-blocking note, PubsubReloadTriggerTaskTest now uses
package-private class/@test visibility and AssertJ assertions (assertThat,
assertThatThrownBy, assertThatCode(...).doesNotThrowAnyException()). The
interface-override methods (onReload/ack/nack) stay public since they override
public API. Adds a test-scoped assertj-core dependency, not previously on the
module's test classpath.




---------

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants