Repository navigation
Release the client connection when a request fails before it is sent - #14457
Merged
dstepanov merged 3 commits intoNov 13, 2026
Merged
Conversation
Only a form encoding failure released the pooled connection. Any other failure while the request was built, e.g. a body no writer can encode, left the connection taken until its read timeout. A failure while the request is set up on the connection now fails the exchange and closes the connection.
…ritten request body The request can be built on the calling thread when the connection was ready before the caller went on, so a failure while it is built released the connection off the event loop, where the pool is not safe to change. The release now runs on the connection's event loop. A failure in a customizer's onRequestPipelineBuilt left a full request body that was taken from the body but not written yet unreleased, because the response handler only releases it while it waits for a 100 Continue.
dstepanov
marked this pull request as ready for review
November 13, 2026 10:40
…ot fail on its own The request line and headers are built by buildNettyRequest before sendRawRequest builds them again through the same builder, so the catch around the second build never ran. The release of a connection now always goes through the event loop. The spec covers a customizer that fails while the request pipeline is built, for a request without a body, with a full body and with a 100 Continue, and a request whose body fails before its connection is open.
|
graemerocher
approved these changes
Nov 13, 2026
dstepanov
deleted the
denis/client-release-connection-on-send-failure
branch
November 13, 2026 12:51
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.



Only a form encoding failure released the pooled connection. Any other
failure while the request was built, e.g. a body no writer can encode, left
the connection taken until its read timeout. A failure while the request is
set up on the connection now fails the exchange and closes the connection.
Tests:
ConnectionLeaseReleaseSpec, which fails with a read timeout without the change.Follow-up commit: the connection is released on its event loop, since the request can be built on the calling thread, and a full request body that was taken but not written is released when a customizer's
onRequestPipelineBuiltthrows.ConnectionLeaseReleaseSpecnow covers a customizer passed to the client builder that fails while the request pipeline is built (without a body, with a full body and with a 100 Continue). A customizer registered with the context cannot reach this path: the composite customizer logs and drops its exceptions.