Author: slaurent
Date: Tue May 20 20:36:14 2014
New Revision: 1596401
URL: http://svn.apache.org/r1596401
Log:
fixed timing and enclosed thread.join in a finally to avoid stopping the webapp
before the request is finished (in case of assertion failure)
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TestStuckThreadDetectionValve.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1596390
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TestStuckThreadDetectionValve.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TestStuckThreadDetectionValve.java?rev=1596401&r1=1596400&r2=1596401&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TestStuckThreadDetectionValve.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TestStuckThreadDetectionValve.java
Tue May 20 20:36:14 2014
@@ -51,7 +51,7 @@ public class TestStuckThreadDetectionVal
@Test
public void testDetection() throws Exception {
// second, we test the actual effect of the flag on the startup
- StuckingServlet stuckingServlet = new StuckingServlet(5000L);
+ StuckingServlet stuckingServlet = new StuckingServlet(6000L);
Wrapper servlet = Tomcat.addServlet(context, "myservlet",
stuckingServlet);
servlet.addMapping("/myservlet");
@@ -78,14 +78,15 @@ public class TestStuckThreadDetectionVal
};
asyncThread.start();
-
- Thread.sleep(1000L);
- Assert.assertEquals(0, valve.getStuckThreadIds().length);
-
- Thread.sleep(2000L);
- Assert.assertEquals(1, valve.getStuckThreadIds().length);
-
- asyncThread.join();
+ try {
+ Thread.sleep(500L);
+ Assert.assertEquals(0, valve.getStuckThreadIds().length);
+
+ Thread.sleep(3000L);
+ Assert.assertEquals(1, valve.getStuckThreadIds().length);
+ } finally {
+ asyncThread.join();
+ }
Assert.assertFalse(stuckingServlet.wasInterrupted);
Assert.assertTrue(result.toString().startsWith("OK"));
}
@@ -101,7 +102,7 @@ public class TestStuckThreadDetectionVal
StuckThreadDetectionValve valve = new StuckThreadDetectionValve();
valve.setThreshold(2);
- valve.setInterruptThreadThreshold(4);
+ valve.setInterruptThreadThreshold(5);
context.addValve(valve);
context.setBackgroundProcessorDelay(1);
tomcat.start();
@@ -122,18 +123,16 @@ public class TestStuckThreadDetectionVal
};
asyncThread.start();
-
- Thread.sleep(1000L);
- Assert.assertEquals(0, valve.getStuckThreadIds().length);
-
- Thread.sleep(3000L);
- Assert.assertEquals(1, valve.getStuckThreadIds().length);
-
- Thread.sleep(3000L);
- Assert.assertTrue(stuckingServlet.wasInterrupted);
- Assert.assertEquals(0, valve.getStuckThreadIds().length);
-
- asyncThread.join();
+ try {
+ Thread.sleep(4000L);
+ Assert.assertEquals(1, valve.getStuckThreadIds().length);
+
+ Thread.sleep(4000L);
+ Assert.assertTrue(stuckingServlet.wasInterrupted);
+ Assert.assertEquals(0, valve.getStuckThreadIds().length);
+ } finally {
+ asyncThread.join();
+ }
Assert.assertTrue(result.toString().startsWith("OK"));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]