Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

WFLY-2923 Remove weak hash map from the WorkCacheManager #5966

Merged
merged 1 commit into from

2 participants

@stuartwdouglas

Replace with an explicit unload on undeploy

@wildfly-ci
Collaborator

Build 2801 is now running using a merge of 537000a

@wildfly-ci
Collaborator

Build 2801 outcome was SUCCESS using a merge of 537000a
Summary: Tests passed: 5601, ignored: 79 Build time: 1:29:52

@stuartwdouglas stuartwdouglas merged commit 537000a into wildfly:master

1 check passed

Details default TeamCity Build WildFly :: Pull request finished: Tests passed: 5601, ignored: 79
@stuartwdouglas

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2014
  1. @stuartwdouglas

    WFLY-2923 Remove weak hash map from the WorkCacheManager

    stuartwdouglas authored
    Replace with an explicit unload on undeploy
This page is out of date. Refresh to see the latest.
View
14 jacorb/src/main/java/org/jboss/as/jacorb/deployment/JacORBMarkerProcessor.java
@@ -21,10 +21,15 @@
*/
package org.jboss.as.jacorb.deployment;
+import org.jboss.as.jacorb.rmi.ExceptionAnalysis;
+import org.jboss.as.jacorb.rmi.InterfaceAnalysis;
+import org.jboss.as.jacorb.rmi.ValueAnalysis;
+import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.modules.Module;
/**
* Processor responsible for marking a deployment as using IIOP
@@ -41,7 +46,14 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
@Override
public void undeploy(final DeploymentUnit context) {
-
+ //clear data from the relevant caches
+ Module module = context.getAttachment(Attachments.MODULE);
+ if(module == null) {
+ return;
+ }
+ ExceptionAnalysis.clearCache(module.getClassLoader());
+ InterfaceAnalysis.clearCache(module.getClassLoader());
+ ValueAnalysis.clearCache(module.getClassLoader());
}
}
View
4 jacorb/src/main/java/org/jboss/as/jacorb/rmi/ExceptionAnalysis.java
@@ -43,6 +43,10 @@ public static ExceptionAnalysis getExceptionAnalysis(Class cls)
return (ExceptionAnalysis) cache.getAnalysis(cls);
}
+ public static void clearCache(final ClassLoader classLoader) {
+ cache.clearClassLoader(classLoader);
+ }
+
protected ExceptionAnalysis(Class cls) {
super(cls);
}
View
3  jacorb/src/main/java/org/jboss/as/jacorb/rmi/InterfaceAnalysis.java
@@ -53,6 +53,9 @@ public static InterfaceAnalysis getInterfaceAnalysis(Class cls) throws RMIIIOPVi
return (InterfaceAnalysis) cache.getAnalysis(cls);
}
+ public static void clearCache(final ClassLoader classLoader) {
+ cache.clearClassLoader(classLoader);
+ }
protected InterfaceAnalysis(Class cls) {
super(cls);
View
4 jacorb/src/main/java/org/jboss/as/jacorb/rmi/ValueAnalysis.java
@@ -85,6 +85,10 @@ public static ValueAnalysis getValueAnalysis(Class cls) throws RMIIIOPViolation
return (ValueAnalysis) cache.getAnalysis(cls);
}
+ public static void clearCache(final ClassLoader classLoader) {
+ cache.clearClassLoader(classLoader);
+ }
+
protected ValueAnalysis(final Class cls) {
super(cls);
}
View
76 jacorb/src/main/java/org/jboss/as/jacorb/rmi/WorkCacheManager.java
@@ -28,9 +28,10 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
import java.util.HashMap;
-import java.util.WeakHashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.jboss.as.jacorb.JacORBMessages;
@@ -51,13 +52,37 @@
* unfinished analysis will be returned if the same thread is already
* working on this analysis.
*
- * TODO: this looks like a big class loader leak waiting to happen
- *
* @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
*/
class WorkCacheManager {
/**
+ * The analysis constructor of our analysis class.
+ * This constructor takes a single argument of type <code>Class</code>.
+ */
+ private final Constructor constructor;
+
+ /**
+ * The analysis initializer of our analysis class.
+ * This method takes no arguments, and is named doAnalyze.
+ */
+ private final Method initializer;
+
+ /**
+ * This maps the classes of completely done analyses to soft
+ * references of their analysis.
+ */
+ private final Map<Class, SoftReference<ContainerAnalysis>> workDone;
+
+ /**
+ * This maps the classes of analyses in progress to their
+ * analysis.
+ */
+ private final Map<InProgressKey, ContainerAnalysis> workInProgress;
+
+ private final Map<ClassLoader, Set<Class<?>>> classesByLoader;
+
+ /**
* Create a new work cache manager.
*
* @param cls The class of the analysis type we cache here.
@@ -70,9 +95,16 @@
} catch (NoSuchMethodException ex) {
throw JacORBMessages.MESSAGES.unexpectedException(ex);
}
-
- workDone = new WeakHashMap<Class, SoftReference<ContainerAnalysis>>();
+ workDone = new HashMap<Class, SoftReference<ContainerAnalysis>>();
workInProgress = new HashMap<InProgressKey, ContainerAnalysis>();
+ classesByLoader = new HashMap<ClassLoader, Set<Class<?>>>();
+ }
+
+ public void clearClassLoader(final ClassLoader cl) {
+ Set<Class<?>> classes = classesByLoader.remove(cl);
+ if(classes != null) {
+ workInProgress.remove(cl);
+ }
}
/**
@@ -108,6 +140,14 @@ ContainerAnalysis getAnalysis(final Class cls) throws RMIIIOPViolationException
workInProgress.remove(new InProgressKey(cls, Thread.currentThread()));
if(ret != null) {
workDone.put(cls, new SoftReference<ContainerAnalysis>(ret));
+ ClassLoader classLoader = cls.getClassLoader();
+ if(classLoader != null) {
+ Set<Class<?>> classes = classesByLoader.get(classLoader);
+ if(classes == null) {
+ classesByLoader.put(classLoader, classes = new HashSet<Class<?>>());
+ }
+ classes.add(cls);
+ }
}
notifyAll();
}
@@ -116,30 +156,6 @@ ContainerAnalysis getAnalysis(final Class cls) throws RMIIIOPViolationException
}
/**
- * The analysis constructor of our analysis class.
- * This constructor takes a single argument of type <code>Class</code>.
- */
- private final Constructor constructor;
-
- /**
- * The analysis initializer of our analysis class.
- * This method takes no arguments, and is named doAnalyze.
- */
- private final Method initializer;
-
- /**
- * This maps the classes of completely done analyses to soft
- * references of their analysis.
- */
- private final Map<Class, SoftReference<ContainerAnalysis>> workDone;
-
- /**
- * This maps the classes of analyses in progress to their
- * analysis.
- */
- private final Map<InProgressKey, ContainerAnalysis> workInProgress;
-
- /**
* Lookup an analysis in the fully done map.
*/
private ContainerAnalysis lookupDone(Class cls) {
Something went wrong with that request. Please try again.