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 32c2e19d94546653e2cc18656d4df32d3a9bb1db
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Aug 18 20:24:53 2020 +0100

    Refactor for more consistent error code after client sends stream reset
---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java  | 7 ++-----
 test/org/apache/coyote/http2/TestHttp2Section_5_1.java | 2 +-
 webapps/docs/changelog.xml                             | 5 +++++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 08ff5e7..62e1423 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -38,7 +38,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import javax.servlet.http.WebConnection;
 
 import org.apache.coyote.Adapter;
-import org.apache.coyote.CloseNowException;
 import org.apache.coyote.ProtocolException;
 import org.apache.coyote.Request;
 import org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler;
@@ -836,9 +835,7 @@ public class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpU
             do {
                 synchronized (this) {
                     if (!stream.canWrite()) {
-                        throw new CloseNowException(
-                                
sm.getString("upgradeHandler.stream.notWritable",
-                                        stream.getConnectionId(), 
stream.getIdentifier()));
+                        
stream.doStreamCancel(sm.getString("upgradeHandler.stream.notWritable"), 
Http2Error.STREAM_CLOSED);
                     }
                     long windowSize = getWindowSize();
                     if (windowSize < 1 || backLogSize > 0) {
@@ -910,7 +907,7 @@ public class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpU
                                     error = Http2Error.ENHANCE_YOUR_CALM;
                                 } else {
                                     msg = sm.getString("stream.clientCancel");
-                                    error = Http2Error.CANCEL;
+                                    error = Http2Error.STREAM_CLOSED;
                                 }
                                 // Close the stream
                                 // This thread is in application code so need
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java 
b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
index 7bf83dd..c9182c8 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
@@ -321,7 +321,7 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
             // Client reset triggers a write error which in turn triggers a 
server
             // reset
             parser.readFrame(true);
-            Assert.assertEquals("3-RST-[8]\n", output.getTrace());
+            Assert.assertEquals("3-RST-[5]\n", output.getTrace());
             output.clearTrace();
 
             // Open up the connection window.
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c703e00..8a8ef8e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -99,6 +99,11 @@
         in the previous release to reduce the memory footprint of closed HTTP/2
         streams. (markt)
       </fix>
+      <fix>
+        Refactor the HTTP/2 implementation to more consistently return a stream
+        closed error if errors occur after a stream has been reset by the
+        client. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="WebSocket">


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

Reply via email to