You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/09/20 13:22:49 UTC

svn commit: r1524977 - /tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java

Author: markt
Date: Fri Sep 20 11:22:49 2013
New Revision: 1524977

URL: http://svn.apache.org/r1524977
Log:
Attempt to address intermittent failures suspect to be caused by timing issues

Modified:
    tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java

Modified: tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java?rev=1524977&r1=1524976&r2=1524977&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java (original)
+++ tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderExecutorMemoryLeak.java Fri Sep 20 11:22:49 2013
@@ -61,14 +61,19 @@ public class TestWebappClassLoaderExecut
         // Stop the context
         ctx.stop();
 
-        // If the thread still exists, we have a thread/memory leak
-        try {
-            Thread.sleep(1000);
-        } catch (InterruptedException ie) {
-            // ignore
+        // Should be shutdown once the stop() method above exists
+        Assert.assertTrue(executorServlet.tpe.isShutdown());
+
+        // The time taken to shutdown the executor can vary between systems. Try
+        // to avoid false test failures due to timing issues. Give the executor
+        // upto 10 seconds to close down.
+        int count = 0;
+        while (count < 100 && !executorServlet.tpe.isTerminated()) {
+            count++;
+            Thread.sleep(100);
         }
 
-        Assert.assertTrue(executorServlet.tpe.isShutdown());
+        // If the executor has not terminated, there is a thread/memory leak
         Assert.assertTrue(executorServlet.tpe.isTerminated());
     }
 



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