HHH-14541 Only mark the session factory as closed *after* SessionFactoryObserver#sessionFactoryClosing was called

This commit is contained in:
Andrea Boriero 2021-05-12 17:27:14 +02:00
parent eb4e397a04
commit f7ab5f315d
1 changed files with 5 additions and 5 deletions

View File

@ -535,7 +535,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
protected void validateNotClosed() { protected void validateNotClosed() {
if ( Status.CLOSED == status ) { if ( status == Status.CLOSED ) {
throw new IllegalStateException( "EntityManagerFactory is closed" ); throw new IllegalStateException( "EntityManagerFactory is closed" );
} }
} }
@ -625,7 +625,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
private <K,V> Session buildEntityManager(final SynchronizationType synchronizationType, final Map<K,V> map) { private <K,V> Session buildEntityManager(final SynchronizationType synchronizationType, final Map<K,V> map) {
assert Status.CLOSED != status; assert status != Status.CLOSED;
SessionBuilderImplementor builder = withOptions(); SessionBuilderImplementor builder = withOptions();
if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) { if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) {
@ -694,7 +694,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
@Override @Override
public boolean isOpen() { public boolean isOpen() {
return Status.CLOSED != status; return status != Status.CLOSED;
} }
@Override @Override
@ -792,7 +792,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
@Override @Override
public void close() throws HibernateException { public void close() throws HibernateException {
synchronized (this) { synchronized (this) {
if ( Status.OPEN != status ) { if ( status != Status.OPEN ) {
if ( getSessionFactoryOptions().getJpaCompliance().isJpaClosedComplianceEnabled() ) { if ( getSessionFactoryOptions().getJpaCompliance().isJpaClosedComplianceEnabled() ) {
throw new IllegalStateException( "EntityManagerFactory is already closed" ); throw new IllegalStateException( "EntityManagerFactory is already closed" );
} }
@ -988,7 +988,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
@Override @Override
public boolean isClosed() { public boolean isClosed() {
return Status.CLOSED == status; return status == Status.CLOSED;
} }
private transient StatisticsImplementor statistics; private transient StatisticsImplementor statistics;