From 1d3124e06d2148d814e317286b6d9d571d827401 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 15 Dec 2024 15:46:04 +0100 Subject: [PATCH] very minor cleanup in SessionImpl --- .../org/hibernate/internal/SessionImpl.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 5a820190a5..ef1323ca75 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -448,25 +448,30 @@ public class SessionImpl private boolean isTransactionInProgressAndNotMarkedForRollback() { if ( waitingForAutoClose ) { return getSessionFactory().isOpen() - && getTransactionCoordinator().isTransactionActive( false ); + && isTransactionActive(); } else { return !isClosed() - && getTransactionCoordinator().isTransactionActive( false ); + && isTransactionActive(); } } + private boolean isTransactionActive() { + return getTransactionCoordinator().isTransactionActive( false ); + } + @Override protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) { - if ( !isTransactionCoordinatorShared ) { - return super.shouldCloseJdbcCoordinatorOnClose( isTransactionCoordinatorShared ); + if ( isTransactionCoordinatorShared ) { + final ActionQueue actionQueue = getActionQueue(); + if ( actionQueue.hasBeforeTransactionActions() || actionQueue.hasAfterTransactionActions() ) { + log.warn( "On close, shared Session had before/after transaction actions that have not yet been processed" ); + } + return false; } - - final ActionQueue actionQueue = getActionQueue(); - if ( actionQueue.hasBeforeTransactionActions() || actionQueue.hasAfterTransactionActions() ) { - log.warn( "On close, shared Session had before/after transaction actions that have not yet been processed" ); + else { + return true; } - return false; } @Override