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 ed2c073f19 Fix intermittent
TestHttp2Section_5_1.testClosedInvalidFrame01 failure
ed2c073f19 is described below
commit ed2c073f1944b6c5e2359aeb43fa8e020d02ede2
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Dec 2 13:25:01 2026 +0000
Fix intermittent TestHttp2Section_5_1.testClosedInvalidFrame01 failure
Resetting the stream fails the servlet's read of the request body. If the
servlet then writes to the stream, a RST_STREAM frame may be sent before the
GOAWAY frame triggered by the DATA frame. Skip any such frames.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
test/org/apache/coyote/http2/Http2TestBase.java | 15 +++++++++++++++
test/org/apache/coyote/http2/TestHttp2Section_5_1.java | 4 +++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java
b/test/org/apache/coyote/http2/Http2TestBase.java
index 6a8c2ce7b6..9766401fdf 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1030,8 +1030,23 @@ public abstract class Http2TestBase extends
TomcatBaseTest {
void handleGoAwayResponse(int lastStream, Http2Error expectedError) throws
Http2Exception, IOException {
+ handleGoAwayResponse(lastStream, expectedError, false);
+ }
+
+
+ /*
+ * skipStreamResets should be true if the test can't control whether the
server sends a RST_STREAM frame before the
+ * GOAWAY frame. For example, if the servlet is still processing a stream
that the test has reset, the servlet may
+ * write to it. RST_STREAM frames are skipped until the first frame that
is not a RST_STREAM frame.
+ */
+ void handleGoAwayResponse(int lastStream, Http2Error expectedError,
boolean skipStreamResets)
+ throws Http2Exception, IOException {
try {
parser.readFrame();
+ while (skipStreamResets &&
output.getTrace().matches("(?s)^\\d+-RST-.*")) {
+ output.clearTrace();
+ parser.readFrame();
+ }
Assert.assertTrue(output.getTrace(),
output.getTrace().startsWith("0-Goaway-[" + lastStream +
"]-[" + expectedError.getCode() + "]-["));
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
index 24fd9063ab..21decde1b3 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
@@ -174,7 +174,9 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
// Then try sending some data (which should fail)
sendData(3, new byte[] {});
- handleGoAwayResponse(3, Http2Error.STREAM_CLOSED);
+ // The reset also fails the servlet's read of the request body. If the
servlet then writes to the stream, the
+ // GOAWAY may be preceded by a RST_STREAM for the stream so skip any.
+ handleGoAwayResponse(3, Http2Error.STREAM_CLOSED, true);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]