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

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

commit fc30f97326862af3a577b1c0bfe2397382de798d
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 bf0565d..0e489e8 100644
--- a/java/org/apache/coyote/http2/Http2Parser.java
+++ b/java/org/apache/coyote/http2/Http2Parser.java
@@ -208,7 +208,7 @@ class Http2Parser {
                 if (endOfStream) {
                     output.receivedEndOfStream(streamId);
                 }
-                output.endRequestBodyFrame(streamId);
+                output.endRequestBodyFrame(streamId, dataLength);
             }
         }
     }
@@ -747,7 +747,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 dcc6c18..994a7cb 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -1481,10 +1481,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 3a92861..7cee15a 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1031,7 +1031,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

Reply via email to