CAMEL-24174: Strip JPA EntityManager property in parallel multicast, recipientList and wireTap#24795
Conversation
…l multicast, recipientList and wireTap Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Review: CAMEL-24174 — Strip JPA EntityManager property in parallel multicast, recipientList and wireTap
Verdict: Approve ✅
This is a straightforward extension of the CAMEL-22534 fix (commit 20764a2811c1) that was applied to Splitter but missed three other EIPs that also copy exchanges for concurrent processing.
Consistency with the Splitter fix:
The pattern is identical across all three files — copy.removeProperty(Exchange.JPA_ENTITY_MANAGER) to prevent sharing a non-thread-safe EntityManager map across parallel branches:
MulticastProcessor— guarded byisParallelProcessing(), placed right aftersetTransacted()✓RecipientListProcessor— guarded byisParallelProcessing(), same position ✓WireTapProcessor— unconditional (correct: wire tap always runs asynchronously on a separate thread) ✓
Key design points:
- No JPA dependency in
camel-core-processor—Exchange.JPA_ENTITY_MANAGERis a string constant ("CamelEntityManager") defined incamel-api, so the core processor module stays lightweight. - When the property is removed,
JpaHelper.getTargetEntityManager()falls through to creating a dedicatedEntityManagerper branch, which is the correct thread-safe behavior. - The placement is right after
createCorrelatedCopy()+setTransacted(), matching the Splitter's pattern.
Minimal, focused, and correct.
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.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 544 tested, 29 compile-only — current: 544 all testedMaveniverse Scalpel detected 573 affected modules (current approach: 544).
|
Summary
CAMEL-22534 fixed a concurrency issue where the Splitter shared the non-thread-safe JPA
EntityManagermap across parallel sub-exchanges. The same fix was missing from three other EIPs:CamelEntityManagerwhenparallelProcessingis enabledCamelEntityManagerwhenparallelProcessingis enabledCamelEntityManagersince wire tap runs asynchronouslyWhen the property is removed, the JPA component creates a fresh dedicated EntityManager for each branch, avoiding concurrent access to a non-thread-safe EM and HashMap corruption.
No JPA dependency is introduced in
camel-core-processor— the property key is just a string constant fromExchange.Test plan
camel-core-processorbuilds successfullyJpaWireTapTestpassesClaude Code on behalf of davsclaus
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com