This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 272f267b022d CAMEL-24128: camel-jpa - Fix EntityManager leak in
JpaPollingConsumer (#24791)
272f267b022d is described below
commit 272f267b022dd7fa743350b7ea5aa4cebf5a883e
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Jul 16 15:40:57 2026 +0200
CAMEL-24128: camel-jpa - Fix EntityManager leak in JpaPollingConsumer
(#24791)
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../java/org/apache/camel/component/jpa/JpaPollingConsumer.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git
a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaPollingConsumer.java
b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaPollingConsumer.java
index 0564411a47c1..d0391956d87b 100644
---
a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaPollingConsumer.java
+++
b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaPollingConsumer.java
@@ -124,11 +124,11 @@ public class JpaPollingConsumer extends
PollingConsumerSupport {
@Override
public Exchange receive() {
+ Exchange exchange = getEndpoint().createExchange();
+
// resolve the entity manager before evaluating the expression
- final EntityManager entityManager = getTargetEntityManager(null,
entityManagerFactory,
+ final EntityManager entityManager = getTargetEntityManager(exchange,
entityManagerFactory,
getEndpoint().isUsePassedInEntityManager(),
getEndpoint().isSharedEntityManager(), true);
-
- Exchange exchange = getEndpoint().createExchange();
exchange.getIn().setHeader(JpaConstants.ENTITY_MANAGER, entityManager);
transactionStrategy.executeInTransaction(new Runnable() {
@Override