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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to