HHH-16150 Fix a little issue with SessionFactoryImpl#disintegrate

This commit is contained in:
Christian Beikov 2023-02-07 17:42:55 +01:00
parent 97d5057751
commit 1a9f545e79
1 changed files with 10 additions and 5 deletions

View File

@ -371,7 +371,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
}
catch ( Exception e ) {
disintegrate( integratorObserver );
disintegrate( e, integratorObserver );
try {
close();
@ -453,11 +453,16 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
}
}
private void disintegrate(IntegratorObserver integratorObserver) {
for ( Integrator integrator : serviceRegistry.getService( IntegratorService.class ).getIntegrators() ) {
private void disintegrate(Exception startupException, IntegratorObserver integratorObserver) {
for ( Integrator integrator : integratorObserver.integrators ) {
try {
integrator.disintegrate( this, serviceRegistry );
integratorObserver.integrators.remove( integrator );
}
catch (Throwable ex) {
startupException.addSuppressed( ex );
}
}
integratorObserver.integrators.clear();
}