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 29d944a600 Only assert what is guaranteed when the connection is 
closed with queued streams
29d944a600 is described below

commit 29d944a600e78d1700ea5ac69ce170aad533d848
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 27 22:54:55 2026 +0000

    Only assert what is guaranteed when the connection is closed with queued 
streams
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 .../coyote/http2/TestHttp2QueuedStreams.java       | 38 +++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/test/org/apache/coyote/http2/TestHttp2QueuedStreams.java 
b/test/org/apache/coyote/http2/TestHttp2QueuedStreams.java
index 793f01dd1d..5abdb4964f 100644
--- a/test/org/apache/coyote/http2/TestHttp2QueuedStreams.java
+++ b/test/org/apache/coyote/http2/TestHttp2QueuedStreams.java
@@ -248,14 +248,17 @@ public class TestHttp2QueuedStreams extends Http2TestBase 
{
             Thread.sleep(50);
         }
         Assert.assertEquals(0, blocked.get());
+        /*
+         * The notification for the started asynchronous request is processed. 
Whether the other events queued by the
+         * close are also processed depends on writes to the closed socket 
completing so is not asserted here.
+         */
         Assert.assertEquals("onError() calls", 1, asyncErrors.get());
-        waitForQueuedStreams(0);
-        waitForRetainedStreams(0);
     }
 
 
     /*
-     * Nothing in the queue will be processed once the connection has closed 
so it must be released.
+     * Streams that are waiting to start processing never will once the 
connection has closed so they must be
+     * released.
      */
     @Test
     public void testQueueIsClearedOnClose() throws Exception {
@@ -271,7 +274,12 @@ public class TestHttp2QueuedStreams extends Http2TestBase {
 
         handler.close();
 
-        waitForQueuedStreams(0);
+        /*
+         * Streams that have not started processing are released. Events 
queued for streams that have started (e.g. the
+         * error notifications queued by the close) stay in the queue. They 
are processed as execution slots become
+         * available which, as the socket is closed, depends on writes 
completing so it is not asserted here.
+         */
+        waitForNoQueuedStreamStarts();
     }
 
 
@@ -337,6 +345,28 @@ public class TestHttp2QueuedStreams extends Http2TestBase {
     }
 
 
+    private void waitForNoQueuedStreamStarts() throws Exception {
+        Field queueField = 
Http2UpgradeHandler.class.getDeclaredField("queuedRunnable");
+        queueField.setAccessible(true);
+
+        int waiting = -1;
+        long end = System.nanoTime() + 5_000_000_000L;
+        while (System.nanoTime() < end) {
+            waiting = 0;
+            for (Object streamRunnable : (Queue<?>) queueField.get(handler)) {
+                if (((StreamRunnable) streamRunnable).isInitial()) {
+                    waiting++;
+                }
+            }
+            if (waiting == 0) {
+                return;
+            }
+            Thread.sleep(50);
+        }
+        Assert.assertEquals("queued stream starts", 0, waiting);
+    }
+
+
     private void waitForRetainedStreams(int expected) throws Exception {
         Field retainedField = 
Http2UpgradeHandler.class.getDeclaredField("retainedQueuedStreams");
         retainedField.setAccessible(true);


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

Reply via email to