tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1141944 - /tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
Date Fri, 01 Jul 2011 14:05:00 GMT
Author: markt
Date: Fri Jul  1 14:05:00 2011
New Revision: 1141944

URL: http://svn.apache.org/viewvc?rev=1141944&view=rev
Log:
If things go wrong, don't wait forever for the latch.

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java?rev=1141944&r1=1141943&r2=1141944&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Fri Jul  1 14:05:00
2011
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
@@ -455,6 +456,7 @@ public class TestStandardWrapper extends
             implements javax.servlet.SingleThreadModel {
 
         private static final long serialVersionUID = 1L;
+        private static final long LATCH_TIMEOUT = 60;
 
         private int data = 0;
 
@@ -462,16 +464,22 @@ public class TestStandardWrapper extends
         protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                 throws ServletException, IOException {
 
+            boolean latchAwaitResult = false;
+            
             // Ensure all threads have their own instance of the servlet
             latch.countDown();
             try {
-                latch.await();
+                latchAwaitResult = latch.await(LATCH_TIMEOUT, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
                 // Ignore
             }
 
             resp.setContentType("text/plain");
-            resp.getWriter().print(data);
+            if (latchAwaitResult) {
+                resp.getWriter().print(data);
+            } else {
+                resp.getWriter().print("Latch await failed");
+            }
             resp.getWriter().print(",");
             resp.getWriter().print(hashCode());
         }



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


Mime
View raw message