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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 78da9f864e Make test more robust
78da9f864e is described below

commit 78da9f864e2017a3b645dce00fe4c51657630132
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 b852917857..4264ea90f1 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