Skip to content

Pool acquisition timeout - #6608

Merged
vietj merged 1 commit into
masterfrom
pool-acquire-timeout
Dec 2, 2026
Merged

vietj merged 1 commit into
masterfrom
pool-acquire-timeout

Conversation

@vietj

@vietj vietj commented Dec 2, 2026

Copy link
Copy Markdown
Member

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

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>
@vietj vietj added this to the 5.3.0 milestone Dec 2, 2026
@vietj
vietj merged commit cfb62cf into master Dec 2, 2026
14 of 15 checks passed
@vietj
vietj deleted the pool-acquire-timeout branch December 2, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant