Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

Stuart Douglas WildFly CI
Stuart Douglas

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

Stuart Douglas stuartwdouglas merged commit 537000a into from
Stuart Douglas

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. Stuart Douglas

    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.
14 jacorb/src/main/java/org/jboss/as/jacorb/deployment/JacORBMarkerProcessor.java
View
@@ -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());
}
}
4 jacorb/src/main/java/org/jboss/as/jacorb/rmi/ExceptionAnalysis.java
View
@@ -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);
}
3  jacorb/src/main/java/org/jboss/as/jacorb/rmi/InterfaceAnalysis.java
View
@@ -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);
4 jacorb/src/main/java/org/jboss/as/jacorb/rmi/ValueAnalysis.java
View
@@ -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);
}
76 jacorb/src/main/java/org/jboss/as/jacorb/rmi/WorkCacheManager.java
View
@@ -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.