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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new ec7c412141 Improve error message when cancelling stream due to an 
invalid write
ec7c412141 is described below

commit ec7c412141d0e174558a54c67f771cad507335e4
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 7 13:00:36 2022 +0000

    Improve error message when cancelling stream due to an invalid write
---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 ++-
 java/org/apache/coyote/http2/LocalStrings.properties  | 2 +-
 java/org/apache/coyote/http2/StreamStateMachine.java  | 3 +++
 webapps/docs/changelog.xml                            | 5 +++++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 8ff3bd59d0..8ead0b378d 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -937,7 +937,8 @@ class Http2UpgradeHandler extends AbstractStream implements 
InternalHttpUpgradeH
             synchronized (this) {
                 if (!stream.canWrite()) {
                     
stream.doStreamCancel(sm.getString("upgradeHandler.stream.notWritable",
-                            stream.getConnectionId(), stream.getIdAsString()), 
Http2Error.STREAM_CLOSED);
+                            stream.getConnectionId(), stream.getIdAsString(), 
stream.state.getCurrentStateName() ),
+                            Http2Error.STREAM_CLOSED);
                 }
                 long windowSize = getWindowSize();
                 if (stream.getConnectionAllocationMade() > 0) {
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties 
b/java/org/apache/coyote/http2/LocalStrings.properties
index 615e6413dc..8972c4fb6e 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -155,7 +155,7 @@ upgradeHandler.startRequestBodyFrame.result=Connection 
[{0}], Stream [{1}] start
 upgradeHandler.stream.closed=Stream [{0}] has been closed for some time
 upgradeHandler.stream.error=Connection [{0}], Stream [{1}] Closed due to error
 upgradeHandler.stream.even=A new remote stream ID of [{0}] was requested but 
all remote streams must use odd identifiers
-upgradeHandler.stream.notWritable=Connection [{0}], Stream [{1}], This stream 
is not writable
+upgradeHandler.stream.notWritable=Connection [{0}], Stream [{1}], This stream 
is in state [{2}] and is not writable
 upgradeHandler.stream.old=A new remote stream ID of [{0}] was requested but 
the most recent stream was [{1}]
 upgradeHandler.tooManyRemoteStreams=The client attempted to use more than 
[{0}] active streams
 upgradeHandler.tooMuchOverhead=Connection [{0}], Too much overhead so the 
connection will be closed
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 72028fd4a4..6ec79ff81c 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -164,6 +164,9 @@ class StreamStateMachine {
         stateChange(State.IDLE, State.CLOSED_FINAL);
     }
 
+    final synchronized String getCurrentStateName() {
+        return state.name();
+    }
 
     private enum State {
         IDLE               (false, false, false, true,
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9ecaaff4d3..915f2c17c9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -141,6 +141,11 @@
         A single space rather than a single dash should be used to separate the
         day, month and year components to be compliant with RFC 6265. (markt)
       </fix>
+      <add>
+        Include the name of the current stream state in the error message when 
a
+        stream is cancelled due to an attempt to write to the stream when it is
+        in a state that does not permit writes. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to