Repository navigation
Fail a request whose replay throws before it is sent - #2415
Merged
Merged
Conversation
When a filter asks for a replay, NettyRequestSender.replayRequest hands the previous channel over and then calls sendNextRequest, which builds the replayed request and can throw, for example when the request's body file is gone. replayRequest let that exception through. For a replay that an IOExceptionFilter asked for from a handler's catch block, the exception then left that catch block and reached exceptionCaught. Over HTTP/1.1, the previous channel's drain callback still names the future, so exceptionCaught failed the request. Over HTTP/2, the stream channel is discarded before the replay (since AsyncHttpClient#2197), so exceptionCaught found no future, and the request waited until its request timeout. Abort the future in replayRequest instead, as retry() does for the same call. Pass the previous channel, as replayRequest's earlier aborts do, so that an HTTP/1.1 connection's permit is back before the caller learns of the failure. Claude Code on behalf of Matthias Kurz Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hyperxpro
approved these changes
Nov 27, 2026
3 tasks done
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.
Motivation: When a filter asks for a replay,
NettyRequestSender.replayRequesthands the previous channel over and then callssendNextRequest, which builds the replayed request and can throw, for example when the request's body file is gone.replayRequestlet that exception through.For a replay that an
IOExceptionFilterasks for from a handler's catch block, after anIOException, the exception then left that catch block and reachedexceptionCaught:exceptionCaughtfailed the request.exceptionCaughtfound no future, and the request waited until its request timeout, 60 seconds by default.Example: a POST with a
Filebody over HTTP/2 gets a 307 after the file was deleted. The redirect refuses to resend the missing file with anIOException, anIOExceptionFilterreplays the request, and building that replay throwsIllegalArgumentExceptionfromNettyFileBody.Modification:
replayRequestaborts the future itself whensendNextRequestthrows, asretry()does for the same call. It passes the previous channel, asreplayRequestalready does when rebinding cookies oronRetryfails. That way an HTTP/1.1 connection's permit is back before the caller learns of the failure. The HTTP/2 stream channel holds no permit and is already closed at that point.Result: In that case, the request now fails at once with the exception that stopped the replay, over HTTP/2 as over HTTP/1.1. Over HTTP/1.1 the outcome is the same as before: the request fails with the same exception, and the previous connection is closed with it.
Tests:
FailedReplayHttp2Test: the example above.IllegalArgumentExceptionwithin 10 seconds, after exactly one replay, and the client still serves a later request.FailedReplayTest: the same over HTTP/1.1, through TLS, because over plain HTTP a filter does not replay while the connection is open.maxConnectionsis 1, and the first request'sonThrowablesends the next request. That request needs the permit of the connection the replay came from, at the moment the caller learns of the failure.exceptionCaughtaborted with the channel.nullinstead of the channel fails it withTooManyConnectionsException.The request fails with the exception that stopped the replay, not with the
IOExceptionthat led to it, as withretry().AI disclosure
Claude Code on behalf of Matthias Kurz. The commit includes
Co-Authored-ByperAGENTS.md.Test plan
All on JDK 11.
./mvnw -B -ntp -Dgpg.skip=true clean verify: 2,493 tests, 0 failures, 22 skipped; Revapi passed against 3.0.15. Docker was not running, so the skipped tests include the Testcontainers proxy tests.FailedReplayHttp2TestandFailedReplayTest5 times: 2 of 2 each time.FailedReplayHttp2Testfails with aTimeoutExceptionafter 10 seconds;FailedReplayTestpasses.nullinstead of the channel:FailedReplayTestfails withTooManyConnectionsException;FailedReplayHttp2Testpasses.