This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 0197b1e93ba6dc0352d22f23e668a35c0db521f3 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Mar 17 11:21:22 2021 +0000 Additional fix for BZ 65179 --- java/org/apache/coyote/http2/Http2Parser.java | 4 ++-- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 9 ++++++++- test/org/apache/coyote/http2/Http2TestBase.java | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2Parser.java b/java/org/apache/coyote/http2/Http2Parser.java index 2da5049..f4298d7 100644 --- a/java/org/apache/coyote/http2/Http2Parser.java +++ b/java/org/apache/coyote/http2/Http2Parser.java @@ -196,7 +196,7 @@ class Http2Parser { if (endOfStream) { output.receivedEndOfStream(streamId); } - output.endRequestBodyFrame(streamId); + output.endRequestBodyFrame(streamId, dataLength); } } } @@ -670,7 +670,7 @@ class Http2Parser { // Data frames ByteBuffer startRequestBodyFrame(int streamId, int payloadSize, boolean endOfStream) throws Http2Exception; - void endRequestBodyFrame(int streamId) throws Http2Exception, IOException; + void endRequestBodyFrame(int streamId, int dataLength) throws Http2Exception, IOException; void receivedEndOfStream(int streamId) throws ConnectionException; /** * Notification triggered when the parser swallows some or all of a DATA diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index aa72fa0..4c5ab94 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -1588,10 +1588,17 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH @Override - public void endRequestBodyFrame(int streamId) throws Http2Exception, IOException { + public void endRequestBodyFrame(int streamId, int dataLength) throws Http2Exception, IOException { AbstractNonZeroStream abstractNonZeroStream = getAbstractNonZeroStream(streamId, true); if (abstractNonZeroStream instanceof Stream) { ((Stream) abstractNonZeroStream).getInputBuffer().onDataAvailable(); + } else { + // The Stream was recycled between the call in Http2Parser to + // startRequestBodyFrame() and the synchronized block that contains + // the call to this method. This means the bytes read will have been + // written to the original stream and, effectively, swallowed. + // Therefore, need to notify that those bytes were swallowed here. + onSwallowedDataFramePayload(streamId, dataLength); } } diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java index a848c55..dc41ab3 100644 --- a/test/org/apache/coyote/http2/Http2TestBase.java +++ b/test/org/apache/coyote/http2/Http2TestBase.java @@ -1043,7 +1043,7 @@ public abstract class Http2TestBase extends TomcatBaseTest { @Override - public void endRequestBodyFrame(int streamId) throws Http2Exception { + public void endRequestBodyFrame(int streamId, int dataLength) throws Http2Exception { if (bodyBuffer != null) { if (bodyBuffer.limit() > 0) { trace.append(lastStreamId + "-Body-"); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org