Index: java/org/apache/catalina/loader/WebappClassLoader.java =================================================================== --- java/org/apache/catalina/loader/WebappClassLoader.java (revision 922011) +++ java/org/apache/catalina/loader/WebappClassLoader.java (working copy) @@ -111,6 +111,10 @@ * @author Craig R. McClanahan * @version $Revision$ $Date$ */ +/** + * @author slaurent + * + */ public class WebappClassLoader extends URLClassLoader implements Reloader, Lifecycle @@ -249,7 +253,7 @@ /** - * Construct a new ClassLoader with no defined repositories and no + * Construct a new ClassLoader with no defined repositories but a * parent ClassLoader. */ public WebappClassLoader(ClassLoader parent) { @@ -1970,7 +1974,7 @@ for (Thread thread : threads) { if (thread != null) { ClassLoader ccl = thread.getContextClassLoader(); - if (ccl != null && ccl == this) { + if (ccl == this) { // Don't warn about this thread if (thread == Thread.currentThread()) { continue; @@ -2169,8 +2173,7 @@ boolean remove = false; // Check the key Object key = ((Reference) table[j]).get(); - if (this.equals(key) || (key != null && - this == key.getClass().getClassLoader())) { + if (this.equals(key) || isLoadedByThisWebAppClassLoader(key)) { remove = true; } // Check the value @@ -2178,18 +2181,17 @@ table[j].getClass().getDeclaredField("value"); valueField.setAccessible(true); Object value = valueField.get(table[j]); - if (this.equals(value) || (value != null && - this == value.getClass().getClassLoader())) { + if (this.equals(value) || isLoadedByThisWebAppClassLoader(value)) { remove = true; } if (remove) { Object[] args = new Object[4]; if (key != null) { - args[0] = key.getClass().getCanonicalName(); + args[0] = getPrettyClassName(key.getClass()); args[1] = key.toString(); } if (value != null) { - args[2] = value.getClass().getCanonicalName(); + args[2] = getPrettyClassName(value.getClass()); args[3] = value.toString(); } if (value == null) { @@ -2220,6 +2222,30 @@ } } } + + private String getPrettyClassName(Class clazz) { + String name = clazz.getCanonicalName(); + if(name==null){ + name = clazz.getName(); + } + return name; + } + + /** + * @param o object to test + * @return true if o has been loaded by the current classloader or one of its descendants. + */ + private boolean isLoadedByThisWebAppClassLoader(Object o) { + if(o == null) { + return false; + } + for(ClassLoader loader = o.getClass().getClassLoader(); loader != null; loader = loader.getParent()) { + if(loader == this) { + return true; + } + } + return false; + } /* * Get the set of current threads as an array.