Avoid annotation readings in or lazy initialization of AbstractServiceRegistryImpl

Description

We checked that it is possible that some annotations are read after that the SessionFactory instance has been created.
See this pull request.

Here is an instance of stack frames:

java.lang.reflect.Method.getAnnotation(Method.java) org.hibernate.service.internal.AbstractServiceRegistryImpl.applyInjections(AbstractServiceRegistryImpl.java:293) org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:283) org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:98) org.hibernate.internal.SessionFactoryImpl.getStatistics(SessionFactoryImpl.java:975) org.hibernate.internal.SessionImpl.<init>(SessionImpl.java:245)

For a classic Java stateful application that is fine, but it would be an issue if we executed the same code with GraalVM, using for instance the Quarkus native generation.

For the new cloud native paradigm, code is supposed to be run in an immutable PAAS. It imposes a stateless approach: all the choices and initialization must me done before a pod/container runs.

Trello

Activity

Show:

Details

Assignee

Reporter

Components

Fix versions

Priority

Created October 16, 2019 at 7:10 AM
Updated April 19, 2021 at 12:20 PM