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 8cc3b8fb3f Improve handling of unexpected errors during HTTP/2 
processing
8cc3b8fb3f is described below

commit 8cc3b8fb3f2d8d4d6a757e014f19d1fafa948a60
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Mar 19 03:47:11 2025 +0000

    Improve handling of unexpected errors during HTTP/2 processing
---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java | 8 ++++++++
 java/org/apache/coyote/http2/LocalStrings.properties  | 1 +
 webapps/docs/changelog.xml                            | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 57ea29075d..809ef47bf2 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -48,6 +48,7 @@ import org.apache.coyote.http2.Http2Parser.Input;
 import org.apache.coyote.http2.Http2Parser.Output;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.parser.Priority;
 import org.apache.tomcat.util.log.UserDataHelper;
@@ -442,6 +443,13 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
                 log.debug(sm.getString("upgradeHandler.ioerror", 
connectionId), ioe);
             }
             close();
+        } catch (Throwable t) {
+            ExceptionUtils.handleThrowable(t);
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("upgradeHandler.throwable", 
connectionId), t);
+            }
+            // Unexpected errors close the connection.
+            close();
         }
 
         if (log.isTraceEnabled()) {
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties 
b/java/org/apache/coyote/http2/LocalStrings.properties
index bb79e5a3d4..694c8c92a3 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -166,6 +166,7 @@ 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 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.throwable=Connection [{0}]
 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
 upgradeHandler.unexpectedAck=Connection [{0}], Stream [{1}], A settings 
acknowledgement was received when not expected
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8e615d6659..87722c0862 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -134,6 +134,9 @@
         <bug>69614</bug>: HTTP/2 priority frames with an invalid priority field
         value should be ignored. (markt)
       </fix>
+      <fix>
+        Improve handling of unexpected errors during HTTP/2 processing. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>


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

Reply via email to