Skip to content

Commit b767478

Browse files
committed
Improve handling of unexpected errors during HTTP/2 processing
1 parent b98e74f commit b767478

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

java/org/apache/coyote/http2/Http2UpgradeHandler.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.coyote.http2.Http2Parser.Output;
4848
import org.apache.juli.logging.Log;
4949
import org.apache.juli.logging.LogFactory;
50+
import org.apache.tomcat.util.ExceptionUtils;
5051
import org.apache.tomcat.util.http.MimeHeaders;
5152
import org.apache.tomcat.util.http.parser.Priority;
5253
import org.apache.tomcat.util.log.UserDataHelper;
@@ -439,6 +440,13 @@ public SocketState upgradeDispatch(SocketEvent status) {
439440
log.debug(sm.getString("upgradeHandler.ioerror", connectionId), ioe);
440441
}
441442
close();
443+
} catch (Throwable t) {
444+
ExceptionUtils.handleThrowable(t);
445+
if (log.isDebugEnabled()) {
446+
log.debug(sm.getString("upgradeHandler.throwable", connectionId), t);
447+
}
448+
// Unexpected errors close the connection.
449+
close();
442450
}
443451

444452
if (log.isTraceEnabled()) {

java/org/apache/coyote/http2/LocalStrings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ upgradeHandler.stream.error=Connection [{0}], Stream [{1}] Closed due to error
160160
upgradeHandler.stream.even=A new remote stream ID of [{0}] was requested but all remote streams must use odd identifiers
161161
upgradeHandler.stream.notWritable=Connection [{0}], Stream [{1}], This stream is in state [{2}] and is not writable
162162
upgradeHandler.stream.old=A new remote stream ID of [{0}] was requested but the most recent stream was [{1}]
163+
upgradeHandler.throwable=Connection [{0}]
163164
upgradeHandler.tooManyRemoteStreams=The client attempted to use more than [{0}] active streams
164165
upgradeHandler.tooMuchOverhead=Connection [{0}], Too much overhead so the connection will be closed
165166
upgradeHandler.unexpectedAck=Connection [{0}], Stream [{1}], A settings acknowledgement was received when not expected

webapps/docs/changelog.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@
134134
<bug>69614</bug>: HTTP/2 priority frames with an invalid priority field
135135
value should be ignored. (markt)
136136
</fix>
137+
<fix>
138+
Improve handling of unexpected errors during HTTP/2 processing. (markt)
139+
</fix>
137140
</changelog>
138141
</subsection>
139142
</section>

0 commit comments

Comments
 (0)