You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/21 12:34:10 UTC
[camel] branch master updated: CAMEL-14761
JPAMessageIdRepository.contains() release db connection fix (#3662)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new e65e2fe CAMEL-14761 JPAMessageIdRepository.contains() release db connection fix (#3662)
e65e2fe is described below
commit e65e2fee469c370980de0af9b0c8b10ef0095f8c
Author: kosciej <za...@gmail.com>
AuthorDate: Sat Mar 21 13:33:56 2020 +0100
CAMEL-14761 JPAMessageIdRepository.contains() release db connection fix (#3662)
---
.../idempotent/jpa/JpaMessageIdRepository.java | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java b/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
index c3b0b84..a88d186 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
@@ -145,12 +145,24 @@ public class JpaMessageIdRepository extends ServiceSupport implements Idempotent
if (isJoinTransaction()) {
entityManager.joinTransaction();
}
-
- List<?> list = query(entityManager, messageId);
- if (list.isEmpty()) {
- return Boolean.FALSE;
- } else {
- return Boolean.TRUE;
+ try {
+ List<?> list = query(entityManager, messageId);
+ if (list.isEmpty()) {
+ return Boolean.FALSE;
+ } else {
+ return Boolean.TRUE;
+ }
+ } catch (Exception ex) {
+ LOG.error("Something went wrong trying to check message in repository {}", ex);
+ throw new PersistenceException(ex);
+ } finally {
+ try {
+ if (entityManager.isOpen()) {
+ entityManager.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
}
}
});