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 2019/11/25 13:17:01 UTC

[tomcat] branch 7.0.x updated: Fix potential test failure / hang if timing isn't as expected

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
     new 609d102  Fix potential test failure / hang if timing isn't as expected
609d102 is described below

commit 609d10230ad1cb67c9745764ccee98450df89880
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 25 11:36:33 2019 +0000

    Fix potential test failure / hang if timing isn't as expected
---
 test/org/apache/catalina/core/TestAsyncContextStateChanges.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/org/apache/catalina/core/TestAsyncContextStateChanges.java b/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
index 9c7e723..3e5cb46 100644
--- a/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
+++ b/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
@@ -85,6 +85,7 @@ public class TestAsyncContextStateChanges extends TomcatBaseTest {
     private ServletRequest servletRequest = null;
     private AsyncContext asyncContext = null;
     private AtomicBoolean failed = new AtomicBoolean();
+    private CountDownLatch servletLatch;
     private CountDownLatch threadLatch;
     private CountDownLatch closeLatch;
     private CountDownLatch endLatch;
@@ -98,6 +99,7 @@ public class TestAsyncContextStateChanges extends TomcatBaseTest {
 
         // Initialise tracking fields
         failed.set(true);
+        servletLatch = new CountDownLatch(1);
         threadLatch = new CountDownLatch(1);
         closeLatch = new CountDownLatch(1);
         endLatch = new CountDownLatch(1);
@@ -123,6 +125,9 @@ public class TestAsyncContextStateChanges extends TomcatBaseTest {
         client.connect();
         client.sendRequest();
 
+        // Wait for Servlet to start processing request
+        servletLatch.await();
+
         if (asyncEnd.isError()) {
             client.disconnect();
             closeLatch.countDown();
@@ -155,6 +160,8 @@ public class TestAsyncContextStateChanges extends TomcatBaseTest {
         @Override
         protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                 throws ServletException, IOException {
+            servletLatch.countDown();
+
             if (dispatch) {
                 return;
             }


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