If the ThreadLocal is set to null, there won't be a memory leak but GC is required...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 9 Feb 2010 11:17:05 +0000 (11:17 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 9 Feb 2010 11:17:05 +0000 (11:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@908002 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/loader/LocalStrings.properties
java/org/apache/catalina/loader/WebappClassLoader.java

index 0919bbb..fe1dbac 100644 (file)
@@ -37,6 +37,7 @@ webappClassLoader.readError=Resource read error: Could not load {0}.
 webappClassLoader.clearJbdc=A web application registered the JBDC driver [{0}] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
 webappClassLoader.clearRmiInfo=Failed to find class sun.rmi.transport.Target to clear context class loader. This is expected on non-Sun JVMs.
 webappClassLoader.clearRmiFail=Failed to clear context class loader referenced from sun.rmi.transport.Target 
+webappClassLoader.clearThreadLocalDebug=A web application created a ThreadLocal with key of type [{0}] (value [{1}]). The ThreadLocal has been correctly set to null and the key will be removed by GC. However, to simplify the process of tracing memory leaks, the key has been forcibly removed.
 webappClassLoader.clearThreadLocal=A web application created a ThreadLocal with key of type [{0}] (value [{1}]) and a value of type [{2}] (value [{3}]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
 webappClassLoader.clearThreadLocalFail=Failed to clear ThreadLocal references
 webappClassLoader.stopThreadFail=Failed to terminate thread named [{0}]
index db1a11a..17fb6ab 100644 (file)
@@ -2170,9 +2170,17 @@ public class WebappClassLoader
                                 args[2] = value.getClass().getCanonicalName();
                                 args[3] = value.toString();
                             }
-                            log.error(sm.getString(
-                                    "webappClassLoader.clearThreadLocal",
-                                    args));
+                            if (value == null) {
+                                if (log.isDebugEnabled()) {
+                                    log.debug(sm.getString(
+                                            "webappClassLoader.clearThreadLocal",
+                                            args));
+                                }
+                            } else {
+                                log.error(sm.getString(
+                                        "webappClassLoader.clearThreadLocal",
+                                        args));
+                            }
                             mapRemove.invoke(map, entry);
                         }
                     }