HHH-17347 Support for JDK which do not support JFR events

This commit is contained in:
Andrea Boriero 2023-11-13 13:23:20 +01:00 committed by Steve Ebersole
parent afbce7cf8a
commit 9f1f8e6c09
4 changed files with 7 additions and 10 deletions

View File

@ -561,6 +561,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
private final JpaCompliance jpaCompliance;
private static final EmptyJdbcObserver EMPTY_JDBC_OBSERVER = EmptyJdbcObserver.INSTANCE;
TransactionCoordinator transactionCoordinator;
private final EmptyEventManager eventManager;
public TemporaryJdbcSessionOwner(
JdbcConnectionAccess jdbcConnectionAccess,
@ -590,6 +591,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
.getDefaultConnectionHandlingMode();
}
this.jpaCompliance = new MutableJpaComplianceImpl( Collections.emptyMap(), false );
this.eventManager = new EmptyEventManager();
}
@Override
@ -639,7 +641,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
@Override
public EventManager getEventManager() {
return EmptyEventManager.INSTANCE;
return eventManager;
}
@Override

View File

@ -17,13 +17,8 @@ import org.hibernate.event.spi.FlushEvent;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
public class EmptyEventManager implements EventManager {
public final class EmptyEventManager implements EventManager {
public static final EmptyEventManager INSTANCE = new EmptyEventManager();
private EmptyEventManager(){
}
@Override
public HibernateEvent beginSessionOpenEvent() {
return null;

View File

@ -275,7 +275,7 @@ public final class FastSessionServices {
this.batchBuilder = serviceRegistry.getService( BatchBuilder.class );
final Collection<EventManager> eventManagers = classLoaderService.loadJavaServices( EventManager.class );
this.eventManager = eventManagers.isEmpty()
? EmptyEventManager.INSTANCE
? new EmptyEventManager()
: eventManagers.iterator().next();
}

View File

@ -19,9 +19,9 @@ dependencies {
// JfrUnit requires JDK 17
compileTestJava.onlyIf{
jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit
jdkVersions.test.release.asInt() >= 17
}
test.onlyIf {
jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit
jdkVersions.test.release.asInt() >= 17
}