Skip to content

CAMEL-24184: Fix 19 medium-severity findings from camel-cxf code review#24941

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

CAMEL-24184: Fix 19 medium-severity findings from camel-cxf code review#24941
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24184

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

Fixes all 19 medium-severity findings from the July 2026 AI-assisted code review of the components/camel-cxf/ component family (CAMEL-24184).

The high-severity findings (CAMEL-24176 through CAMEL-24183) were already fixed in separate PRs. This PR addresses the remaining medium-severity items across 6 CXF sub-modules (15 files changed).

camel-cxf-soap / camel-cxf-common

camel-cxf-rest

camel-cxf-transport

camel-cxf-spring-*

Test plan

  • mvn test in camel-cxf-common — passed
  • mvn test in camel-cxf-soap — passed
  • mvn test in camel-cxf-rest — passed
  • mvn test in camel-cxf-transport — passed
  • mvn test in camel-cxf-spring-soap — passed
  • mvn test in camel-cxf-spring-rest — passed

Claude Code on behalf of davsclaus

🤖 Generated with Claude Code

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus davsclaus self-assigned this Jul 20, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 20, 2026
@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.

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

Thorough analysis of 19 medium-severity CXF fixes — each one targeted and well-reasoned. This follows the high-severity fixes already merged in PRs #24929#24934. Verified each fix against the existing codebase patterns:

Correctness bugs (critical fixes):

  • #1 replaceMultiPartContentType: After part.substring(5) strips type=, the else branch did part.substring(5) again — double-stripping turned text/xmlxml. Fix to result = part is correct.
  • #5 & #6 Void.class vs Void.TYPE: Classic Java reflection bug. Method.getReturnType() returns void.class (i.e., Void.TYPE), never Void.class. The checks never matched, so InOnly MEP was never selected for void methods. Fix correctly checks both.
  • #11 CxfConverter entity null: Response.getEntity() returns null for 204/empty responses → NPE in the fallback converter. Returning MISS_VALUE is correct.

NPE guards (defensive fixes):

  • #2 CxfClientCallback: getOutMessage() can be null during failover — guard added.
  • #10 setProtocolHeaders: Rewrites the guard to early-return instead of falling through to use getOutMessage() unconditionally later.
  • #13 asyncInvokeFromWorkQueue: instanceof PhaseInterceptorChain instead of hard cast, plus null guard on fault observer. The LOG.error fallback is appropriate — silent swallowing would be worse.

Resource leaks:

  • #7 InOnly Response leak: When isOutCapable() is false, the Response was never closed — connection stays pinned until GC. Fix correctly closes it.
  • #12 CamelConduit use-after-stop: volatile boolean closed flag + check in prepare() prevents use after close(). Simple and effective.

Header handling (data-loss fixes):

  • #8 Multi-valued Camel→CXF: toString() on a List produced "[a, b]" literal. Fix preserves List values via CastUtils.cast.
  • #9 CXF→Camel truncation: get(0) drops all values after the first. Fix preserves multi-valued headers as List when size() > 1 — good backward-compatible approach.
  • #3 Protocol headers on fault path: Headers stored only on the out-message (which doesn't exist yet in the fault path). Fix also stores on the CXF exchange so headers survive into fault handling.

Thread safety and lifecycle:

  • #4 bus volatile: Prevents visibility issues in lazy init (the getBus() method creates a bus if null).
  • #15-16 enableSpringBusShutdownGracefully: Three improvements: (a) now called from setApplicationContext() for shared bus case (was only called from getBus() for created bus), (b) identity-based listener matching instead of class-name string search, (c) thread only spawned for ContextClosedEvent instead of every ApplicationEvent.

Spring integration:

  • #17 performInvocation: Propagated to SpringJAXRSServerFactoryBean via override.
  • #18 setProperties merge: putAll instead of replace preserves NullFaultListener from constructor.
  • #19 SpringCamelContext cast: instanceof pattern matching prevents ClassCastException in camel-main, with null-safe configurer usage downstream.

Code cleanup:

  • #14 getBasePath regex: Combined two replaceFirst calls (second was unreachable) into a single regex with capture group. Clean.

All fixes follow existing patterns and are well-scoped. This complements the high-severity CXF fixes in #24929#24934 nicely.

LGTM ✅

Claude Code on behalf of gnodet — AI-generated review

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-cxf/camel-cxf-common
  • components/camel-cxf/camel-cxf-rest
  • components/camel-cxf/camel-cxf-soap
  • components/camel-cxf/camel-cxf-spring-rest
  • components/camel-cxf/camel-cxf-spring-soap
  • components/camel-cxf/camel-cxf-transport

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


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

Maveniverse Scalpel detected 51 affected modules (current approach: 22).

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

Modules Scalpel would test (22)
  • camel-cxf-common
  • camel-cxf-rest
  • camel-cxf-soap
  • camel-cxf-spring-rest
  • 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-micrometer-observability
  • camel-observability-services
  • camel-opentelemetry
  • camel-opentelemetry2
  • camel-soap
  • camel-telemetry
  • camel-telemetry-dev
  • 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

Build reactor — dependencies compiled but only changed modules were tested (51 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: CXF :: Common
  • Camel :: CXF :: REST
  • Camel :: CXF :: REST :: Spring
  • 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 :: Common Telemetry
  • 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 :: Micrometer :: Observability 2
  • Camel :: Observability Services
  • Camel :: OpenTelemetry (deprecated)
  • Camel :: Opentelemetry 2
  • Camel :: SOAP
  • Camel :: Telemetry :: Dev
  • 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 added this to the 4.22.0 milestone Jul 20, 2026
@davsclaus
davsclaus merged commit 4ec7639 into main Jul 20, 2026
5 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-24184 branch July 20, 2026 13:19
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