Repository navigation
Pool acquisition timeout - #6608
Merged
Merged
Conversation
Motivation: Every pool waiter should have a deadline: the ground for bounding the wait queue under persistent connect failures. RequestOptions #setConnectTimeout is the pool acquisition timeout; its -1 default used to disable it, leaving the waiter without a deadline. Being connected is relative to the layer connected to: for a pooled request it is obtaining a connection from the pool, so when the request leaves it unset, the connect timeout of the transport being connected to is the natural default. Changes: HttpClientImpl keeps the connect timeout of each transport, passed by the builder, and resolves the acquisition timeout against the version determined for the request when the request options leave it unset. A disabled transport connect timeout cannot provide the default: creating a pooled client with connectTimeout 0 is rejected. HttpConnectOptions documents the default and the distinction with the transport option. DefaultConnectionPool#acquire fails the acquisition with IllegalArgumentException when the timeout is null, zero or negative: the deadline is always set and the eviction guard on the unset deadline is dropped. The pool tests acquire with an oracle timeout. When the connect attempt itself is what times out, the inherited deadline expires with it and the acquisition reports the timeout: testConnectTimeout now expects TimeoutException instead of the Netty ConnectTimeoutException. The new PoolOptions refresh period (default 100 ms, must be positive) drives the periodic refresh performing the pool maintenance tasks and supersedes the deprecated pool cleaner period: the period bounds the resolution of the connect timeout. Assisted-by: Anthropic Claude (claude-fable-5) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Julien Viet <julien@julienviet.com>
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:
Every pool waiter should have a deadline: the ground for bounding the
wait queue under persistent connect failures. RequestOptions
#setConnectTimeout is the pool acquisition timeout; its -1 default used
to disable it, leaving the waiter without a deadline. Being connected
is relative to the layer connected to: for a pooled request it is
obtaining a connection from the pool, so when the request leaves it
unset, the connect timeout of the transport being connected to is the
natural default.
Changes:
HttpClientImpl keeps the connect timeout of each transport, passed by
the builder, and resolves the acquisition timeout against the version
determined for the request when the request options leave it unset. A
disabled transport connect timeout cannot provide the default: creating
a pooled client with connectTimeout 0 is rejected. HttpConnectOptions
documents the default and the distinction with the transport option.
DefaultConnectionPool#acquire fails the acquisition with
IllegalArgumentException when the timeout is null, zero or negative:
the deadline is always set and the eviction guard on the unset deadline
is dropped. The pool tests acquire with an oracle timeout.
When the connect attempt itself is what times out, the inherited
deadline expires with it and the acquisition reports the timeout:
testConnectTimeout now expects TimeoutException instead of the Netty
ConnectTimeoutException.
The new PoolOptions refresh period (default 100 ms, must be positive)
drives the periodic refresh performing the pool maintenance tasks and
supersedes the deprecated pool cleaner period: the period bounds the
resolution of the connect timeout.
Assisted-by: Anthropic Claude (claude-fable-5)
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Signed-off-by: Julien Viet julien@julienviet.com