From f7e3177dba0d664e432be8a0375181794f1ee89b Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 16 Dec 2024 10:15:14 +0100 Subject: [PATCH] very minor code changes --- .../AbstractSharedSessionContract.java | 59 +++++++++---------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index a59c24dbc4..55b4733927 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -461,37 +461,35 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont @Override public void close() { - if ( closed && !waitingForAutoClose ) { - return; - } - - try { - delayedAfterCompletion(); - } - catch ( HibernateException e ) { - if ( getFactory().getSessionFactoryOptions().isJpaBootstrap() ) { - throw getExceptionConverter().convert( e ); + if ( !closed || waitingForAutoClose ) { + try { + delayedAfterCompletion(); } - else { - throw e; + catch ( HibernateException e ) { + if ( getFactory().getSessionFactoryOptions().isJpaBootstrap() ) { + throw getExceptionConverter().convert( e ); + } + else { + throw e; + } } - } - if ( sessionEventsManager != null ) { - sessionEventsManager.end(); - } - - if ( transactionCoordinator != null ) { - removeSharedSessionTransactionObserver( transactionCoordinator ); - } - - try { - if ( shouldCloseJdbcCoordinatorOnClose( isTransactionCoordinatorShared ) ) { - jdbcCoordinator.close(); + if ( sessionEventsManager != null ) { + sessionEventsManager.end(); + } + + if ( transactionCoordinator != null ) { + removeSharedSessionTransactionObserver( transactionCoordinator ); + } + + try { + if ( shouldCloseJdbcCoordinatorOnClose( isTransactionCoordinatorShared ) ) { + jdbcCoordinator.close(); + } + } + finally { + setClosed(); } - } - finally { - setClosed(); } } @@ -553,10 +551,9 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont @Override public boolean isTransactionInProgress() { - if ( waitingForAutoClose ) { - return factory.isOpen() && transactionCoordinator.isTransactionActive(); - } - return !isClosed() && transactionCoordinator.isTransactionActive(); + return waitingForAutoClose + ? factory.isOpen() && transactionCoordinator.isTransactionActive() + : !isClosed() && transactionCoordinator.isTransactionActive(); } @Override