Fail unprocessed local streams on GOAWAY - #711
Merged
Merged
Conversation
rp-arielrodriguez
force-pushed
the
h2-goaway-received-streams
branch
from
September 29, 2026 22:50
6c4a091 to
868347d
Compare
ok2c
approved these changes
Sep 30, 2026
On GOAWAY(NO_ERROR), streams initiated by this endpoint with an id greater than Last-Stream-ID were not processed by the peer and must fail with RequestNotExecutedException (RFC 9113, section 6.8). The check used !isSameSide, so it selected streams initiated by the peer instead. Unprocessed local requests stayed active until the connection was closed and then failed with ConnectionClosedException.
rp-arielrodriguez
force-pushed
the
h2-goaway-received-streams
branch
from
September 30, 2026 13:16
868347d to
8c7dc59
Compare
Member
|
@rp-arielrodriguez Cherry-picked to 5.4.x though I had to port the tests manually. Please double-check. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We found this with HTTP/2 multiplexing in HttpClient 5: when the server sent
GOAWAY(NO_ERROR) during a restart, requests on the same connection that the
server did not process were not failed. They waited until the server closed
the connection.
On GOAWAY(NO_ERROR),
AbstractH2StreamMultiplexermust fail the local streamswith an id greater than Last-Stream-ID with
RequestNotExecutedException(RFC 9113, section 6.8). The check used
!streams.isSameSide(...), so itselected streams initiated by the peer instead.
Fix: drop the negation (one line).
Measured with an end-to-end test (real client, raw-frame server that sends
GOAWAY last-stream-id=1 with stream 3 in flight and closes the connection 3s
later):
ConnectionClosedExceptionafter ~3.2s (at connection close)RequestNotExecutedExceptionimmediatelyStream 1 completes normally in both cases. I did not include that test, to keep
the change small; I can add it if you want it.
The same line is on 5.4.x, so the fix applies there as is.
Tests:
testGoAwayNoErrorFailsUnprocessedLocalStreamsOnly: local stream 3 fails,local stream 1 and remote stream 2 do not (fails on master, passes with the fix).
testGoAwayReservedBitInLastStreamIdAffectsStreamCullingused remotestreams, so it depended on the inverted check. It now uses local streams and
still checks that the reserved bit is masked.
./mvnw -pl httpcore5-h2,httpcore5-testing -am test: all pass (httpcore5-h2387, httpcore5-testing 443 with 4 skipped). Checkstyle and RAT pass.
I used an AI assistant (Claude Code) for this change. I reviewed all of it and
I can answer questions about it.