From f7ab5f315dcdbe60310a347982671f031e6d88c8 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 12 May 2021 17:27:14 +0200 Subject: [PATCH] HHH-14541 Only mark the session factory as closed *after* SessionFactoryObserver#sessionFactoryClosing was called --- .../org/hibernate/internal/SessionFactoryImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 17e3a258e0..ef50a2b8ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -535,7 +535,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { } protected void validateNotClosed() { - if ( Status.CLOSED == status ) { + if ( status == Status.CLOSED ) { throw new IllegalStateException( "EntityManagerFactory is closed" ); } } @@ -625,7 +625,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { } private Session buildEntityManager(final SynchronizationType synchronizationType, final Map map) { - assert Status.CLOSED != status; + assert status != Status.CLOSED; SessionBuilderImplementor builder = withOptions(); if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) { @@ -694,7 +694,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { @Override public boolean isOpen() { - return Status.CLOSED != status; + return status != Status.CLOSED; } @Override @@ -792,7 +792,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { @Override public void close() throws HibernateException { synchronized (this) { - if ( Status.OPEN != status ) { + if ( status != Status.OPEN ) { if ( getSessionFactoryOptions().getJpaCompliance().isJpaClosedComplianceEnabled() ) { throw new IllegalStateException( "EntityManagerFactory is already closed" ); } @@ -988,7 +988,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { @Override public boolean isClosed() { - return Status.CLOSED == status; + return status == Status.CLOSED; } private transient StatisticsImplementor statistics;