When using hibernate with a Container Managed EntityManagerFactory
some classes are loaded outside application classloader.
Every time that a application starts hibernate register JavaTypeDescriptos on JavaTypeDescriptorRegistry.INSTANCE.
The problem is that anybody clean it on application stop, and it is a static instance inside hibernate module classloader.
Possible solution: work with a weak reference of class.
Hibernate 4.3.6 (wildfly)
Thanks for the help .
would a pull request for this (using WeakReference to avoid the memory leak) require additional unit tests in order to be accepted?
The problem with the WeakReference solution is what hints at - namely when those references go away there is nothing in those Maps anymore for other SessionFactories on the same ClassLoader. This is why the change in 6.0 is really the more appropriate change. But regarding the WeakReference, I am not sure of the type of testing we would do anyway.
I know that the hibernate project have its own priorities, but Wildfly 8, 9 and 10 will be on the market for long years, most people only are using 8 and 9, looking for stability.
I agree with you, 6.0 have the more appropriate solution, but many applications will continue to use 4 and 5 versions for many years.
FWIW we define WF modules for all new Hibernate releases (starting in 5.2) - https://repo1.maven.org/maven2/org/hibernate/hibernate-orm-modules/ and you could certainly define yoru own.
I certainly respect people's decision to stick with older versions of things, but they also have to respect the decision of projects to not back port fix to all version back to 1.0
what do you think of a 5.3 release that ports the changes from 6.0 work necessary to scope these registries and avoid this bug? Or do we just expect people to live with this until 6.0?