[jboss-cvs] JBossAS SVN: r65342 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 12 14:31:05 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-09-12 14:31:05 -0400 (Wed, 12 Sep 2007)
New Revision: 65342

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/GenericInterceptorFactory.java
Log:
[JBAOP-226] Fix leak in DynamicTester by making the class in GenericInterceptorFactory.java a weak reference

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/GenericInterceptorFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/GenericInterceptorFactory.java	2007-09-12 17:32:05 UTC (rev 65341)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/GenericInterceptorFactory.java	2007-09-12 18:31:05 UTC (rev 65342)
@@ -21,6 +21,8 @@
   */
 package org.jboss.aop.advice;
 
+import java.lang.ref.WeakReference;
+
 import org.jboss.aop.Advisor;
 import org.jboss.aop.joinpoint.Joinpoint;
 import org.jboss.util.xml.XmlLoadable;
@@ -28,7 +30,7 @@
 
 public class GenericInterceptorFactory implements InterceptorFactory
 {
-   private Class clazz = null;
+   private WeakReference<Class> classRef = null;
    private String classname;
    private Element element;
    private boolean deployed = true;
@@ -45,7 +47,7 @@
 
    public GenericInterceptorFactory(Class clazz)
    {
-      this.clazz = clazz;
+      this.classRef = new WeakReference<Class>(clazz);
       this.classname = clazz.getName();
    }
 
@@ -76,12 +78,18 @@
    {
       try
       {
+         Class clazz = null;
          synchronized (this)
          {
-            if (clazz == null)
+            if (classRef != null)
             {
+               clazz = classRef.get();
+            }
+            if (clazz != null)
+            {
                // FIXME ClassLoader - why should the class be visible from the context classloader?
                clazz = SecurityActions.getContextClassLoader().loadClass(classname);
+               classRef = new WeakReference<Class>(clazz);
             }
          }
          Interceptor interceptor = (Interceptor)clazz.newInstance();




More information about the jboss-cvs-commits mailing list