From 4a65c51326df8f5284b01c8e5e67e977f9895f21 Mon Sep 17 00:00:00 2001 From: Manuel Siggen Date: Thu, 15 Aug 2024 09:54:46 +0200 Subject: [PATCH] HHH-18491 Do no try to resume non-existant transaction in doInSuspendedTransaction. --- .../backend/jta/internal/JtaIsolationDelegate.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java index 8c0012d961e..67cf8c44e3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java @@ -114,7 +114,9 @@ private T doInSuspendedTransaction(HibernateCallable callable) { try { // First we suspend any current JTA transaction final Transaction surroundingTransaction = transactionManager.suspend(); - LOG.debugf( "Surrounding JTA transaction suspended [%s]", surroundingTransaction ); + if ( surroundingTransaction != null ) { + LOG.debugf( "Surrounding JTA transaction suspended [%s]", surroundingTransaction ); + } try { return callable.call(); @@ -124,8 +126,10 @@ private T doInSuspendedTransaction(HibernateCallable callable) { } finally { try { - transactionManager.resume( surroundingTransaction ); - LOG.debugf( "Surrounding JTA transaction resumed [%s]", surroundingTransaction ); + if ( surroundingTransaction != null ) { + transactionManager.resume( surroundingTransaction ); + LOG.debugf( "Surrounding JTA transaction resumed [%s]", surroundingTransaction ); + } } catch ( Throwable t2 ) { // if the actually work had an error use that, otherwise error based on t