tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1574508 - in /tomcat/trunk: java/org/apache/catalina/loader/LocalStrings.properties java/org/apache/catalina/loader/WebappClassLoader.java webapps/docs/changelog.xml
Date Wed, 05 Mar 2014 14:37:38 GMT
Author: kkolinko
Date: Wed Mar  5 14:37:38 2014
New Revision: 1574508

URL: http://svn.apache.org/r1574508
Log:
When reporting threads that are still running while web application is being stopped, print
their stack traces to the log.

Minor fixes:
Remember result of Thread.getName() as that method is not trivial.
Strip trailing whitespaces from changelog.

Modified:
    tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties?rev=1574508&r1=1574507&r2=1574508&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties Wed Mar  5 14:37:38
2014
@@ -39,6 +39,8 @@ webappClassLoader.jarsModified=One or mo
 webappClassLoader.jarsRemoved=One or more JARs have been removed from the web application
[{0}]
 webappClassLoader.javaseClassLoaderNull=The j2seClassLoader attribute may not be null
 webappClassLoader.resourceModified=Resource [{0}] has been modified. The last modified time
was [{1}] and is now [{2}]
+webappClassLoader.stackTrace=Stack trace of thread "{0}":{1}
+webappClassLoader.stackTraceRequestThread=Stack trace of request processing thread "{0}":{1}
 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}

Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1574508&r1=1574507&r2=1574508&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Wed Mar  5 14:37:38
2014
@@ -1772,6 +1772,8 @@ public class WebappClassLoader extends U
                         continue;
                     }
 
+                    final String threadName = thread.getName();
+
                     // JVM controlled threads
                     ThreadGroup tg = thread.getThreadGroup();
                     if (tg != null &&
@@ -1779,7 +1781,7 @@ public class WebappClassLoader extends U
 
                         // HttpClient keep-alive threads
                         if (clearReferencesHttpClientKeepAliveThread &&
-                                thread.getName().equals("Keep-Alive-Timer")) {
+                                threadName.equals("Keep-Alive-Timer")) {
                             thread.setContextClassLoader(parent);
                             log.debug(sm.getString(
                                     "webappClassLoader.checkThreadsHttpClient"));
@@ -1805,10 +1807,14 @@ public class WebappClassLoader extends U
 
                     if (isRequestThread(thread)) {
                         log.error(sm.getString("webappClassLoader.warnRequestThread",
-                                getContextName(), thread.getName()));
+                                getContextName(), threadName));
+                        log.error(sm.getString("webappClassLoader.stackTraceRequestThread",
+                                threadName, getStackTrace(thread)));
                     } else {
                         log.error(sm.getString("webappClassLoader.warnThread",
-                                getContextName(), thread.getName()));
+                                getContextName(), threadName));
+                        log.error(sm.getString("webappClassLoader.stackTrace",
+                                threadName, getStackTrace(thread)));
                     }
 
                     // Don't try an stop the threads unless explicitly
@@ -2125,6 +2131,14 @@ public class WebappClassLoader extends U
         return name;
     }
 
+    private String getStackTrace(Thread thread) {
+        StringBuilder builder = new StringBuilder();
+        for (StackTraceElement ste : thread.getStackTrace()) {
+            builder.append("\n ").append(ste);
+        }
+        return builder.toString();
+    }
+
     /**
      * @param o object to test, may be null
      * @return <code>true</code> if o has been loaded by the current classloader

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1574508&r1=1574507&r2=1574508&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Mar  5 14:37:38 2014
@@ -79,8 +79,13 @@
         invalid request for a resource outside of the web application. (markt)
       </fix>
       <fix>
-        Remove an unnecessary null check identified by FindBugs. (markt) 
+        Remove an unnecessary null check identified by FindBugs. (markt)
       </fix>
+      <add>
+        In WebappClassLoader, when reporting threads that are still running
+        while web application is being stopped, print their stack traces to
+        the log. (kkolinko)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Coyote">
@@ -112,7 +117,7 @@
         (markt)
       </fix>
       <fix>
-        Remove an unnecessary null check identified by FindBugs. (markt) 
+        Remove an unnecessary null check identified by FindBugs. (markt)
       </fix>
     </changelog>
   </subsection>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message