HHH-8363 Some more mem leak fixes
Conflicts: hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java hibernate-envers/src/main/java/org/hibernate/envers/configuration/spi/AuditConfiguration.java hibernate-envers/src/main/java/org/hibernate/envers/event/spi/EnversIntegrator.java
This commit is contained in:
parent
a89e88fa18
commit
2ce3aa1f09
|
@ -52,7 +52,7 @@ import org.jboss.logging.Logger;
|
||||||
public class ClassLoaderServiceImpl implements ClassLoaderService {
|
public class ClassLoaderServiceImpl implements ClassLoaderService {
|
||||||
private static final Logger log = Logger.getLogger( ClassLoaderServiceImpl.class );
|
private static final Logger log = Logger.getLogger( ClassLoaderServiceImpl.class );
|
||||||
|
|
||||||
private final ClassLoader aggregatedClassLoader;
|
private AggregatedClassLoader aggregatedClassLoader;
|
||||||
|
|
||||||
private final Map<Class, ServiceLoader> serviceLoaders = new HashMap<Class, ServiceLoader>();
|
private final Map<Class, ServiceLoader> serviceLoaders = new HashMap<Class, ServiceLoader>();
|
||||||
|
|
||||||
|
@ -256,10 +256,14 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
|
||||||
serviceLoader.reload(); // clear service loader providers
|
serviceLoader.reload(); // clear service loader providers
|
||||||
}
|
}
|
||||||
serviceLoaders.clear();
|
serviceLoaders.clear();
|
||||||
|
if (aggregatedClassLoader!=null){
|
||||||
|
aggregatedClassLoader.destroy();
|
||||||
|
aggregatedClassLoader = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AggregatedClassLoader extends ClassLoader {
|
private static class AggregatedClassLoader extends ClassLoader {
|
||||||
private final ClassLoader[] individualClassLoaders;
|
private ClassLoader[] individualClassLoaders;
|
||||||
|
|
||||||
private AggregatedClassLoader(final LinkedHashSet<ClassLoader> orderedClassLoaderSet) {
|
private AggregatedClassLoader(final LinkedHashSet<ClassLoader> orderedClassLoaderSet) {
|
||||||
super( null );
|
super( null );
|
||||||
|
@ -314,6 +318,10 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
|
||||||
|
|
||||||
throw new ClassNotFoundException( "Could not load requested class : " + name );
|
throw new ClassNotFoundException( "Could not load requested class : " + name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
individualClassLoaders = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,8 +278,10 @@ public abstract class AbstractServiceRegistryImpl
|
||||||
serviceBindingList.clear();
|
serviceBindingList.clear();
|
||||||
}
|
}
|
||||||
serviceBindingMap.clear();
|
serviceBindingMap.clear();
|
||||||
|
|
||||||
parent.destroy();
|
if (parent!=null){
|
||||||
|
parent.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.envers.configuration;
|
package org.hibernate.envers.configuration;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -57,7 +58,7 @@ public class AuditConfiguration {
|
||||||
private final RevisionInfoQueryCreator revisionInfoQueryCreator;
|
private final RevisionInfoQueryCreator revisionInfoQueryCreator;
|
||||||
private final RevisionInfoNumberReader revisionInfoNumberReader;
|
private final RevisionInfoNumberReader revisionInfoNumberReader;
|
||||||
private final ModifiedEntityNamesReader modifiedEntityNamesReader;
|
private final ModifiedEntityNamesReader modifiedEntityNamesReader;
|
||||||
private final ClassLoaderService classLoaderService;
|
private ClassLoaderService classLoaderService;
|
||||||
|
|
||||||
public AuditEntitiesConfiguration getAuditEntCfg() {
|
public AuditEntitiesConfiguration getAuditEntCfg() {
|
||||||
return auditEntCfg;
|
return auditEntCfg;
|
||||||
|
@ -182,4 +183,13 @@ public class AuditConfiguration {
|
||||||
|
|
||||||
return verCfg;
|
return verCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
for (Map.Entry<Configuration, AuditConfiguration> c: new HashSet<Map.Entry<Configuration, AuditConfiguration>>(cfgs.entrySet())){
|
||||||
|
if (c.getValue() == this){//this is nasty cleanup fix, whole static CFGS should be reworked
|
||||||
|
cfgs.remove(c.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
classLoaderService = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class EnversIntegrator implements Integrator {
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, EnversIntegrator.class.getName() );
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, EnversIntegrator.class.getName() );
|
||||||
|
|
||||||
public static final String AUTO_REGISTER = "hibernate.listeners.envers.autoRegister";
|
public static final String AUTO_REGISTER = "hibernate.listeners.envers.autoRegister";
|
||||||
|
private AuditConfiguration enversConfiguration;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void integrate(
|
public void integrate(
|
||||||
|
@ -61,7 +62,7 @@ public class EnversIntegrator implements Integrator {
|
||||||
EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
||||||
listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );
|
listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );
|
||||||
|
|
||||||
final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration, serviceRegistry.getService( ClassLoaderService.class ) );
|
enversConfiguration = AuditConfiguration.getFor( configuration, serviceRegistry.getService( ClassLoaderService.class ) );
|
||||||
|
|
||||||
if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
|
if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
|
||||||
listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
|
listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
|
||||||
|
@ -75,7 +76,7 @@ public class EnversIntegrator implements Integrator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
// nothing to do afaik
|
enversConfiguration.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue