This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 0307169e95 Allow for either outcome in the sendfile test that closes
the connection
0307169e95 is described below
commit 0307169e95ca7e14fd0a719df22758922efd138b
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Dec 2 15:06:08 2026 +0000
Allow for either outcome in the sendfile test that closes the connection
Closing the connection resets the stream. If the write that is in progress
completes, and finds that the stream has been reset, before the clean-up is
performed, it has finished with the request and response so they may be
returned to the pool. Otherwise they must not be. The test only allowed for
the
second outcome so it failed intermittently with NIO2. Accept either outcome
and
check that the request and response are not returned to the pool more than
once.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
test/org/apache/coyote/http2/TestHttp2Sendfile.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/test/org/apache/coyote/http2/TestHttp2Sendfile.java
b/test/org/apache/coyote/http2/TestHttp2Sendfile.java
index 26c16d7d2b..99c68d0d3c 100644
--- a/test/org/apache/coyote/http2/TestHttp2Sendfile.java
+++ b/test/org/apache/coyote/http2/TestHttp2Sendfile.java
@@ -531,10 +531,18 @@ public class TestHttp2Sendfile extends Http2TestBase {
handler.close();
Assert.assertEquals("Stream that was not recycled", 0,
countNotRecycled(Collections.singletonList(stream)));
- // A callback for the write may still be running so the request and
response must not be available for re-use
- // by another stream, possibly on another connection.
- Assert.assertNotSame("The request was returned to the pool",
stream.getCoyoteRequest(),
- http2Protocol.popRequestAndResponse());
+ /*
+ * Closing the connection resets the stream. If the write that is in
progress completes, and finds that the stream
+ * has been reset, before the clean-up is performed, it has finished
with the request and response so they may
+ * be returned to the pool. Otherwise a callback for the write may
still be running so the request and response
+ * must not be available for re-use by another stream, possibly on
another connection. Either is valid but they
+ * must not be returned to the pool more than once.
+ */
+ org.apache.coyote.Request request = stream.getCoyoteRequest();
+ if (request == http2Protocol.popRequestAndResponse()) {
+ Assert.assertNotSame("The request was returned to the pool more
than once", request,
+ http2Protocol.popRequestAndResponse());
+ }
// Stream 1 (the upgrade request) and stream 3. The request must be
counted even though the clean-up was
// triggered by the connection being closed and not by the write
finishing.
Assert.assertEquals("Each request must be counted once", 2,
http2Protocol.getGlobal().getRequestCount());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]