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 11:48:53 UTC

[tomcat] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


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

commit e160e5343f70dbac23e2771303c1a1573d0dd152
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 90f8521..f909484 100644
--- a/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
+++ b/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
@@ -76,6 +76,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;
@@ -89,6 +90,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);
@@ -114,6 +116,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();
@@ -147,6 +152,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