Skip to content

CAMEL-24573: CXF REST: UnsupportedOperationException when copying factory bean, backport to camel-4.22.x - #25969

Merged
davsclaus merged 1 commit into
camel-4.22.xfrom
backport/CAMEL-24573-4.22.x
Aug 31, 2026
Merged

CAMEL-24573: CXF REST: UnsupportedOperationException when copying factory bean, backport to camel-4.22.x#25969
davsclaus merged 1 commit into
camel-4.22.xfrom
backport/CAMEL-24573-4.22.x

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Backport to camel-4.22.x of #25967, a straight cherry-pick already reviewed and merged on main.

Problem. CxfRsSpringEndpoint.newInstanceWithCommonProperties() shallow-copies the features field from the source Spring bean. When that bean's features list is fixed-size (e.g. built with Arrays.asList()), the copy aliases the same immutable list. A later addAll() call in setupCommonFactoryProperties() then throws UnsupportedOperationException.

Fix. Wrap the copied list in a new ArrayList so the copy is mutable, without touching the original Spring bean's list.

Straight cherry-pick of the squash-merge commit, no manual adaptation needed. Built and tested camel-cxf-spring-rest on this branch, including the new testCreateCxfRsClientFactoryBeanWithFixedSizeFeatures.

Claude Code on behalf of davsclaus

Backport of #25967

Original PR: #25967 - CAMEL-24573: CXF REST: UnsupportedOperationException when copying factory bean with fixed-size features list
Original author: @mcarlett
Target branch: camel-4.22.x

…tory bean with fixed-size features list

When creating a CXF JAXRS client factory bean from a Spring bean with a
fixed-size features list (e.g., from Arrays.asList()), the shallow field copy
in CxfRsSpringEndpoint.newInstanceWithCommonProperties() resulted in a
reference to the immutable list. A subsequent attempt to append endpoint
features via addAll() in setupCommonFactoryProperties() then threw
UnsupportedOperationException.

Wrap the copied features list in a new ArrayList so the copy is mutable,
while leaving the original Spring bean's list untouched. Adds
testCreateCxfRsClientFactoryBeanWithFixedSizeFeatures to cover the
fixed-size-list case.

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>

Closes #25967
@davsclaus davsclaus added bug Something isn't working components labels Aug 31, 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.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-cxf/camel-cxf-spring-rest

🔬 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-cxf-spring-rest
  • 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 :: CXF :: REST :: 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 :: 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.

Straight cherry-pick backport of #25967 to camel-4.22.x. The original PR was already reviewed — the fix correctly wraps the shallow-copied features list in a new ArrayList to prevent UnsupportedOperationException when setupCommonFactoryProperties() calls addAll() on a fixed-size list.

No manual adaptation needed. Test included.

📋 PR Metadata

Aspect Current Suggested
Milestone (none) 4.22.1

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

Claude Code on behalf of Guillaume Nodet

@davsclaus davsclaus added this to the 4.22.1 milestone Aug 31, 2026
@davsclaus
davsclaus merged commit 9c2e968 into camel-4.22.x Aug 31, 2026
4 checks passed
@davsclaus
davsclaus deleted the backport/CAMEL-24573-4.22.x branch August 31, 2026 17:57
davsclaus added a commit that referenced this pull request Aug 31, 2026
…tory bean, backport to camel-4.18.x

Backports #25967 to camel-4.18.x. Same fix as #25969: wraps the shallow-copied
features field in a new ArrayList in CxfRsSpringEndpoint.newInstanceWithCommonProperties()
so a fixed-size source list (e.g. Arrays.asList()) doesn't cause
UnsupportedOperationException on a later append.

Not a straight cherry-pick: this branch's camel-cxf-spring-rest test module
depends on camel-test-spring-junit5, not junit6, so the test's import was
kept as-is. More substantially, CxfRsSpringEndpoint.setupJAXRSClientFactoryBean()
on this branch never calls setupCommonFactoryProperties() (that call was
added later by CAMEL-24183, not present here), so the endpoint's own features
are never auto-appended to the copied list. The ported test is adapted to
assert the copied feature is preserved and that the list is mutable by
appending directly, rather than relying on auto-append behaviour this branch
doesn't have.

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

Closes #25970
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