Make memory leak prevention code that clears ThreadLocal instances more robust agains...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 10:38:40 +0000 (10:38 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 10:38:40 +0000 (10:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1038041 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/loader/LocalStrings.properties
java/org/apache/catalina/loader/WebappClassLoader.java
webapps/docs/changelog.xml

index 4350c71..47fd083 100644 (file)
@@ -49,6 +49,9 @@ webappClassLoader.clearThreadLocal=The web application [{0}] created a ThreadLoc
 webappClassLoader.clearThreadLocalDebugClear=To simplify the process of tracing memory leaks, the key has been forcibly removed.
 webappClassLoader.clearThreadLocalClear=To prevent a memory leak, the ThreadLocal has been forcibly removed.
 webappClassLoader.clearThreadLocalFail=Failed to clear ThreadLocal references for web application [{0}]
+webappClassLoader.clearThreadLocal.badKey=Unable to determine string representation of key of type [{0}]
+webappClassLoader.clearThreadLocal.badValue=Unable to determine string representation of value of type [{0}]
+webappClassLoader.clearThreadLocal.unknown=Unknown
 webappClassLoader.stopThreadFail=Failed to terminate thread named [{0}] for web application [{1}]
 webappClassLoader.stopTimerThreadFail=Failed to terminate TimerThread named [{0}] for web application [{1}]
 webappClassLoader.validationErrorJarPath=Unable to validate JAR entry with name {0}
index 8fd6638..36b7d52 100644 (file)
@@ -2442,11 +2442,27 @@ public class WebappClassLoader
                             args[0] = contextName;
                             if (key != null) {
                                 args[1] = key.getClass().getCanonicalName();
-                                args[2] = key.toString();
+                                try {
+                                    args[2] = key.toString();
+                                } catch (Exception e) {
+                                    log.error(sm.getString(
+                                            "webappClassLoader.clearThreadLocal.badKey",
+                                            args[1]), e);
+                                    args[2] = sm.getString(
+                                            "webappClassLoader.clearThreadLocal.unknown");
+                                }
                             }
                             if (value != null) {
                                 args[3] = value.getClass().getCanonicalName();
-                                args[4] = value.toString();
+                                try {
+                                    args[4] = value.toString();
+                                } catch (Exception e) {
+                                    log.error(sm.getString(
+                                            "webappClassLoader.clearThreadLocal.badValue",
+                                            args[3]), e);
+                                    args[4] = sm.getString(
+                                    "webappClassLoader.clearThreadLocal.unknown");
+                                }
                             }
                             if (value == null) {
                                 if (log.isDebugEnabled()) {
index 5d70d27..b55c190 100644 (file)
         <code>AsyncContext.dispatch()</code> once the asynchronous request has
         timed out. (markt)
       </fix>
+      <add>
+        Make memory leak prevention code that clears ThreadLocal instances more
+        robust against objects with toString() methods that throw exceptions.
+        (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Coyote">