Skip to content

CAMEL-23515: camel-nats - Use dedicated HeaderFilterStrategy aligned with sibling components#23233

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23515
May 15, 2026
Merged

CAMEL-23515: camel-nats - Use dedicated HeaderFilterStrategy aligned with sibling components#23233
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23515

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 14, 2026

Summary

camel-nats defaulted its headerFilterStrategy to a bare
new DefaultHeaderFilterStrategy() with no further configuration
(NatsConfiguration.java:119). The base class with no inFilter /
inFilterPattern / inFilterStartsWith configured returns false for
every header, which means every inbound NATS message header is copied
onto the Camel Exchange as-is — including Camel* / camel* /
org.apache.camel.* keys that drive component behaviour downstream.

Sibling components (camel-kafka, camel-mail, camel-coap,
camel-google-pubsub, camel-jms, camel-sjms, …) ship a dedicated subclass
that configures setInFilterStartsWith("Camel", "camel", "org.apache.camel.")
and setLowerCase(true). This PR aligns camel-nats with that
convention.

Changes

  • New NatsHeaderFilterStrategy following the
    KafkaHeaderFilterStrategy / MailHeaderFilterStrategy shape.
  • NatsConfiguration now defaults headerFilterStrategy to
    new NatsHeaderFilterStrategy().
  • Unit test covering inbound/outbound Camel* filtering, lowercase
    variants, and pass-through of non-Camel headers.
  • 4.21 upgrade-guide entry under the existing === camel-nats
    section.

Test plan

  • Module build: mvn -pl components/camel-nats -DskipTests install
  • New unit test: NatsHeaderFilterStrategyTest (4 assertions)
  • CI: full reactor build + existing camel-nats unit/integration tests

JIRA

https://issues.apache.org/jira/browse/CAMEL-23515

Backports planned for 4.18.x and 4.14.x per fixVersions on the JIRA.

Claude Code on behalf of Andrea Cosentino

…with sibling components

Introduce NatsHeaderFilterStrategy following the KafkaHeaderFilterStrategy /
MailHeaderFilterStrategy shape (lowerCase=true, filter headers starting with
Camel/camel/org.apache.camel. in both directions), and switch the default
in NatsConfiguration to use it.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@github-actions
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
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-nats
  • docs
All tested modules (8 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: Nats
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants