Simplify the code and fix an edge case for BZ 64830 · apache/tomcat@dd757c0 · GitHub
Skip to content

Commit

Permalink
Simplify the code and fix an edge case for BZ 64830
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jan 14, 2021
1 parent 9768ef8 commit dd757c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions java/org/apache/coyote/AbstractProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,10 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
if (state == SocketState.UPGRADING) {
// Get the HTTP upgrade handler
UpgradeToken upgradeToken = processor.getUpgradeToken();
// Retrieve leftover input
// Restore leftover input to the wrapper so the upgrade
// processor can process it.
ByteBuffer leftOverInput = processor.getLeftoverInput();
wrapper.unRead(leftOverInput);
if (upgradeToken == null) {
// Assume direct HTTP/2 connection
UpgradeProtocol upgradeProtocol = getProtocol().getUpgradeProtocol("h2c");
Expand All @@ -876,7 +878,6 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
release(processor);
// Create the upgrade processor
processor = upgradeProtocol.getProcessor(wrapper, getProtocol().getAdapter());
wrapper.unRead(leftOverInput);
// Associate with the processor with the connection
wrapper.setCurrentProcessor(processor);
} else {
Expand All @@ -898,7 +899,6 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
getLog().debug(sm.getString("abstractConnectionHandler.upgradeCreate",
processor, wrapper));
}
wrapper.unRead(leftOverInput);
// Associate with the processor with the connection
wrapper.setCurrentProcessor(processor);
// Initialise the upgrade handler (which may trigger
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
</subsection>
<subsection name="Coyote">
<changelog>
<fix>
Additional fix for <bug>64830</bug> to address an edge case that could
trigger request corruption with h2c connections. (markt)
</fix>
<fix>
<bug>64974</bug>: Improve handling of pipelined HTTP requests in
combination with the Servlet non-blocking IO API. It was possible that
Expand Down

0 comments on commit dd757c0

Please sign in to comment.