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

View File

@ -535,7 +535,7 @@ public Map<String, Object> getProperties() {
}
protected void validateNotClosed() {
if ( Status.CLOSED == status ) {
if ( status == Status.CLOSED ) {
throw new IllegalStateException( "EntityManagerFactory is closed" );
}
}
@ -625,7 +625,7 @@ public Session createEntityManager() {
}
private <K,V> Session buildEntityManager(final SynchronizationType synchronizationType, final Map<K,V> map) {
assert Status.CLOSED != status;
assert status != Status.CLOSED;
SessionBuilderImplementor builder = withOptions();
if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) {
@ -694,7 +694,7 @@ public MetamodelImplementor getMetamodel() {
@Override
public boolean isOpen() {
return Status.CLOSED != status;
return status != Status.CLOSED;
}
@Override
@ -792,7 +792,7 @@ public Type getReferencedPropertyType(String className, String propertyName)
@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 <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph
@Override
public boolean isClosed() {
return Status.CLOSED == status;
return status == Status.CLOSED;
}
private transient StatisticsImplementor statistics;