test case : https://github.com/sturmin/hib-proxy-handler-equals-test
AbstractProxyHandler implements equals method in not reflexive way i.e proxy.equals(proxy) returns false.
This leads to certain issue when Hibernate runs on IBM JVM (tested on IBM J9 VM (build 2.4, J2RE 1.6.0 IBM J9 2.4)).
This issue is not reproduced on Oracle JVM due to different implementation of HashMap class. The implementation in Oracle JVM first checks reference equality when object is searched in a map by a key and only if this check fails then object equality is checked.But In IBM JVM object equality is checked always.
When a proxy is released from JdbcResourceRegistryImpl (https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java) it is closed, invalidated but not removed from xref map. After when JdbcResourceRegistryImpl is closed it tries to close all items in xref map but the proxy has been already invalidated and HibernateException(“proxy handle is no longer valid”) occur.
I think this may be the cause of resource leaks. Possibly this issue is related to https://hibernate.onjira.com/browse/HHH-7020
|