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

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


The following commit(s) were added to refs/heads/main by this push:
     new 656bfd4e29 Make test more robust
656bfd4e29 is described below

commit 656bfd4e2973e0dd6241b09ae0f02803a61ee3d4
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Jun 4 10:32:49 2026 +0100

    Make test more robust
---
 .../catalina/valves/TestPersistentValveAsync.java  | 24 ++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/test/org/apache/catalina/valves/TestPersistentValveAsync.java 
b/test/org/apache/catalina/valves/TestPersistentValveAsync.java
index d146b2c1b2..73cfd92d21 100644
--- a/test/org/apache/catalina/valves/TestPersistentValveAsync.java
+++ b/test/org/apache/catalina/valves/TestPersistentValveAsync.java
@@ -218,7 +218,21 @@ public class TestPersistentValveAsync extends 
TomcatBaseTest {
 
         asyncRequest.await();
         asyncRequest.assertResponse(expectedStatus, expectedResponseBody);
-        assertSessionRequestSucceeds(requestHeaders);
+
+        /*
+         * The semaphore will not be released until after 
AsyncListener.onComplete() has been called which will occur
+         * after the error response has been sent to the client. On some CI 
systems the follow-up request occurs before
+         * the listener has completed so allow up to two seconds for the 
listener to complete.
+         */
+        int count = 0;
+        int status = makeSessionRequest();
+        while (status != HttpServletResponse.SC_OK && count < 20) {
+            Thread.sleep(100);
+            count++;
+            status = makeSessionRequest();
+        }
+
+        Assert.assertEquals(HttpServletResponse.SC_OK, status);
     }
 
 
@@ -229,11 +243,9 @@ public class TestPersistentValveAsync extends 
TomcatBaseTest {
     }
 
 
-    private void assertSessionRequestSucceeds(Map<String,List<String>> 
requestHeaders) throws Exception {
-        ByteChunk success = new ByteChunk();
-        int status = getUrl("http://localhost:"; + getPort() + "/session", 
success, requestHeaders, null);
-        Assert.assertEquals(HttpServletResponse.SC_OK, status);
-        Assert.assertFalse(success.isNull());
+    private int makeSessionRequest() throws Exception {
+        ByteChunk body = new ByteChunk();
+        return getUrl("http://localhost:"; + getPort() + "/session", body, 
false);
     }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to