Skip to content

CAMEL-24133: Circuit Breaker EIP - Release correlated copy instead of original exchange in pooled mode#24796

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24133
Jul 16, 2026
Merged

CAMEL-24133: Circuit Breaker EIP - Release correlated copy instead of original exchange in pooled mode#24796
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24133

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

Fixes CAMEL-24133

Both Circuit Breaker EIP implementations (ResilienceProcessor and FaultToleranceProcessor) release the original in-flight exchange back to the processor exchange pool instead of the correlated copy when camel.main.exchange-factory=pooled is enabled.

  • ResilienceProcessor.processTask() called processorExchangeFactory.release(exchange) — the original
  • FaultToleranceProcessor.CircuitBreakerTask.call() — same bug

This causes PooledExchange.done() to wipe the body, properties, exception, and exchangeId of the still-in-use original exchange, resulting in null body downstream and potential cross-exchange corruption under concurrency.

Fix: Release the correlated copy (with null guard) instead of the original exchange, matching the pattern used by Enricher, Splitter, and MulticastProcessor.

Changes

  • ResilienceProcessor.java — change processorExchangeFactory.release(exchange) to processorExchangeFactory.release(copy)
  • FaultToleranceProcessor.java — same change
  • Added ResiliencePooledProcessorExchangeFactoryTest — uses timer: consumer with both PooledExchangeFactory and PooledProcessorExchangeFactory, verifies body survives circuit breaker
  • Added FaultTolerancePooledProcessorExchangeFactoryTest — same test for microprofile-fault-tolerance

Test plan

  • New test ResiliencePooledProcessorExchangeFactoryTest passes (fails without fix)
  • New test FaultTolerancePooledProcessorExchangeFactoryTest passes (fails without fix)
  • All 45 existing camel-resilience4j tests pass
  • All 21 existing camel-microprofile-fault-tolerance tests pass

Claude Code on behalf of davsclaus

… original exchange in pooled mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@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.

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

Review: CAMEL-24133 — Circuit Breaker EIP - Release correlated copy instead of original exchange in pooled mode

Verdict: Approve

Clear-cut bug fix. Both circuit breaker implementations create a correlated copy for processing but release the original exchange back to the pool. In pooled mode, release() calls PooledExchange.done() which wipes body, properties, exception, and exchangeId — destroying the still-in-use original exchange.

Code changes are correct:

  • ResilienceProcessor.processTask()copy is initialized to null at line 569, assigned at line 581 via createCorrelatedCopy(). The null guard at the release point handles the case where copy creation itself throws (caught by the catch(Exception e) at line 607).
  • FaultToleranceProcessor.CircuitBreakerTask.call() — identical structure: copy initialized null (line 410), assigned at line 423, null-guarded release.

Both match the established pattern: create copy → process → ExchangeHelper.copyResults(exchange, copy)UnitOfWorkHelper.doneUow(uow, copy)processorExchangeFactory.release(copy).

Tests are well-structured:

Both tests (ResiliencePooledProcessorExchangeFactoryTest and FaultTolerancePooledProcessorExchangeFactoryTest) configure the critical pooled mode that triggers the bug:

context.getCamelContextExtension().setExchangeFactory(new PooledExchangeFactory());
context.getCamelContextExtension().setProcessorExchangeFactory(new PooledProcessorExchangeFactory());

The assertion body().isEqualTo("Bye World") directly verifies the body survives the circuit breaker — without the fix, it would be null. Uses MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS) per project conventions.

Reviewed with Claude Code (claude-code/1.0.3) on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-microprofile/camel-microprofile-fault-tolerance
  • components/camel-resilience4j

ℹ️ 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: 34 tested, 29 compile-only — current: 34 all tested

Maveniverse Scalpel detected 63 affected modules (current approach: 34).

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

Modules Scalpel would test (34)
  • camel-a2a
  • camel-clickup
  • camel-java-joor-dsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jsonpath
  • camel-kafka
  • camel-knative-http
  • camel-launcher-container
  • camel-micrometer-prometheus
  • camel-microprofile-fault-tolerance
  • camel-netty-http
  • camel-oauth
  • camel-observability-services
  • camel-openapi-validator
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-resilience4j
  • camel-resilience4j-micrometer
  • camel-rest-openapi
  • camel-telegram
  • camel-test-main-junit5
  • camel-test-main-junit6
  • camel-webhook
  • camel-whatsapp
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring
  • 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 (63 modules)
  • Camel :: AI :: A2A
  • 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 :: ClickUp
  • 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 :: JSon Path
  • Camel :: Java DSL with jOOR
  • Camel :: Kafka
  • Camel :: Kamelet Main
  • Camel :: Knative HTTP
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: MicroProfile :: Fault Tolerance
  • Camel :: Micrometer :: Prometheus
  • Camel :: Netty HTTP
  • Camel :: OAuth
  • Camel :: Observability Services
  • Camel :: OpenAPI :: Validator
  • Camel :: Platform HTTP :: Main
  • Camel :: Platform HTTP :: Vert.x
  • Camel :: REST OpenApi
  • Camel :: Resilience4j
  • Camel :: Resilience4j :: Micrometer
  • Camel :: Telegram
  • Camel :: Test :: Main :: JUnit5
  • Camel :: Test :: Main :: JUnit6
  • Camel :: Webhook
  • Camel :: Whatsapp
  • Camel :: XML DSL Jaxb :: Test :: Definition
  • Camel :: XML DSL Jaxb :: Test :: Spring
  • Camel :: XML DSL with camel-xml-io
  • Camel :: XML DSL with camel-xml-jaxb
  • 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 16, 2026
@davsclaus davsclaus self-assigned this Jul 16, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 16, 2026
@davsclaus
davsclaus merged commit 9fa33b8 into main Jul 16, 2026
5 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-24133 branch July 16, 2026 13:41
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