[jboss-cvs] JBossAS SVN: r59609 - trunk/jmx/src/main/org/jboss/mx/loading.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 12 20:38:12 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-12 20:38:10 -0500 (Fri, 12 Jan 2007)
New Revision: 59609

Modified:
   trunk/jmx/src/main/org/jboss/mx/loading/UnifiedClassLoader.java
Log:
Need to validate that an undeployed class loader is not falling into a loop trying to load a class via super.loadClass

Modified: trunk/jmx/src/main/org/jboss/mx/loading/UnifiedClassLoader.java
===================================================================
--- trunk/jmx/src/main/org/jboss/mx/loading/UnifiedClassLoader.java	2007-01-12 22:51:13 UTC (rev 59608)
+++ trunk/jmx/src/main/org/jboss/mx/loading/UnifiedClassLoader.java	2007-01-13 01:38:10 UTC (rev 59609)
@@ -61,6 +61,7 @@
    // Static --------------------------------------------------------
 
    private static final Logger log = Logger.getLogger(UnifiedClassLoader.class);
+   private ThreadLocal<String> delegatedClassName = new ThreadLocal<String>();
 
    // Attributes ----------------------------------------------------
 
@@ -225,11 +226,25 @@
          // If we have been undeployed we can still try locally
          try
          {
+            /* We need validate we are not recursing trying to load a class
+               that does not exist in the parent
+            */
+            String prevName = delegatedClassName.get();
+            if( prevName != null )
+            {
+               if( prevName.equals(name) )
+                  throw new ClassNotFoundException("Recursing on: "+name);
+            }
+            delegatedClassName.set(name);
             return super.loadClass(name, resolve);
          }
          catch (ClassNotFoundException ignored)
          {
          }
+         finally
+         {
+            delegatedClassName.set(null);            
+         }
          String msg = "Invalid use of destroyed classloader, UCL destroyed at:";
          throw new ClassNotFoundException(msg, this.unregisterTrace);
       }




More information about the jboss-cvs-commits mailing list