Skip to content

CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body - #24930

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24180
Jul 20, 2026
Merged

CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body#24930
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24180

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Claude Code on behalf of davsclaus

Summary

  • Fix copy-paste bug in CxfMessageHelper.getCxfInMessage() where the fallback branch (line 63) passed the null body variable instead of message.getBody(), causing non-InputStream message bodies (e.g. POJOs) to arrive as null content in downstream CXF interceptors
  • Add test coverage for the fallback branch with POJO and null bodies

Details

The bug has been dormant since 2011 because most Camel bodies have an InputStream type converter. The else if branch is only reachable when body (the InputStream variable) is null, so answer.setContent(Object.class, body) always set null. The fix changes it to answer.setContent(Object.class, message.getBody()).

Test plan

  • testGetCxfInMessageWithPojoBody — verifies a List body (no InputStream converter) is preserved via the fallback
  • testGetCxfInMessageWithNullBody — verifies null body produces no content (no NPE)
  • Existing testGetCxfInMessage — verifies String/DOMSource/File bodies still work via InputStream path

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

…tual body

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus davsclaus added the bug Something isn't working label Jul 20, 2026
@davsclaus davsclaus added this to the 4.22.0 milestone Jul 20, 2026
@davsclaus
davsclaus requested review from Croway and cunningt July 20, 2026 08:54

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

Clean, well-diagnosed fix for a long-dormant copy-paste bug.

The bug: body is the InputStream variable from message.getBody(InputStream.class), which is guaranteed null in the else if branch (that's why we're in the else if). So answer.setContent(Object.class, body) always set null.

The fix: message.getBody() correctly retrieves the original body. One-line change, exactly right.

Tests: Good coverage of both the POJO fallback path (assertSame confirms identity, not just equality) and the null-body edge case (no NPE, no spurious content).

As the PR description notes, this has been dormant since 2011 because most Camel bodies have an InputStream type converter — the fallback is only reached for types without one (POJOs, custom objects). Low risk, high correctness improvement.

Claude Code on behalf of gnodet — AI-generated review

@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-cxf/camel-cxf-transport

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

Maveniverse Scalpel detected 42 affected modules (current approach: 13).

⚠️ 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 13 modules (1 direct + 12 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (13)
  • camel-cxf-soap
  • camel-cxf-spring-soap
  • camel-cxf-spring-transport
  • camel-cxf-transport
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-soap
  • 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 (42 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: CXF :: SOAP
  • Camel :: CXF :: SOAP :: Spring
  • Camel :: CXF :: Transport
  • Camel :: CXF :: Transport :: Spring
  • 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 :: 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 :: SOAP
  • 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

@davsclaus davsclaus self-assigned this Jul 20, 2026
@davsclaus
davsclaus merged commit ab2ff4d into main Jul 20, 2026
5 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-24180 branch July 20, 2026 10:49
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