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

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

commit d9669e4ec2b9cc0bcfa2f74375bdb8d51f9632cf
Author: Mark Thomas <ma...@apache.org>
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 367fe95..a1feb4d 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -36,7 +36,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;
@@ -839,9 +838,7 @@ class Http2UpgradeHandler extends AbstractStream implements 
InternalHttpUpgradeH
             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) {
@@ -913,7 +910,7 @@ class Http2UpgradeHandler extends AbstractStream implements 
InternalHttpUpgradeH
                                     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 6583b8d..3538516 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
@@ -316,7 +316,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 1037b63..197eac9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -110,6 +110,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: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to