Skip to content

Clarify that the Netty connection acquire timeout includes opening a new connection - #7506

Merged
adev-code merged 2 commits into
masterfrom
gh-6013-netty-acquire-timeout-javadoc
Nov 4, 2026
Merged

adev-code merged 2 commits into
masterfrom
gh-6013-netty-acquire-timeout-javadoc

Conversation

@adev-code

Copy link
Copy Markdown
Contributor

Motivation and Context

Related to #6013

Docs changed by this PR:

CONNECTION_ACQUIRE_TIMEOUT says it is the "Timeout for acquiring an already-established connection from a connection pool". With the Netty client that is not the case: HealthCheckedChannelPool.acquire starts the acquire timer on every acquire, also when a new connection still has to be opened. So when the acquire timeout is shorter than the connection timeout, a request can fail with "Acquire operation took longer than ..." before the connection timeout is reached. The issue shows this with a 5 s acquire timeout and a 10 s connection timeout, and asks that it be called out so users don't set the acquire timeout too small. The same error was reported in jenkinsci/pipeline-aws-plugin#374.

Modifications

  • SdkHttpConfigurationOption.CONNECTION_ACQUIRE_TIMEOUT: drops "already-established" and says that, depending on the HTTP client, this time can also include opening a new connection, with Netty as the example.
  • NettyNioAsyncHttpClient.Builder.connectionAcquisitionTimeout(Duration): says the time also includes opening a new connection when the pool doesn't have one ready, and to set it to at least connectionTimeout(Duration).

Javadoc only, no behavior change. The issue's second comment (a second request failing about 1 s after the first one) is a behavior question and is left for the team; that's why this PR says "Related to" and not "Fixes".

Testing

  • Javadoc only.
  • mvn install -pl :http-client-spi,:netty-nio-client -am with tests: http-client-spi passes. netty-nio-client: 452 JUnit + 212 TestNG tests, 0 failures, 0 Checkstyle violations, 0 SpotBugs issues, with ServerConnectivityErrorMessageTest excluded. That test fails the same way (2 of 16) on master without this change in my local macOS environment, so it is not related.
  • javadoc -Xdoclint:all on both files: no errors, and the new {@link #connectionTimeout(Duration)} resolves.

License

  • I confirm that this pull request can be released under the Apache 2 license

@adev-code adev-code added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Nov 3, 2026
@adev-code
adev-code requested a review from a team as a code owner November 3, 2026 17:59
@adev-code adev-code added the changelog-not-required Indicate changelog entry is not required for a specific PR label Nov 3, 2026
@adev-code
adev-code requested a review from S-Saranya1 November 3, 2026 22:12
* Timeout for acquiring an already-established connection from a connection pool to a remote service.
* Timeout for acquiring a connection from a connection pool to a remote service.
* <p>
* Depending on the HTTP client, this time can also include opening a new connection. For example, the Netty

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Depending on the HTTP client" might leave users unsure which clients count the connection time and which don't. Could we check how each client behaves and say it explicitly? If it's only Netty, we could say "Only the Netty client includes the time to open a new connection", if any client does the same, we can name them. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, thanks. I tested each client with a 2 s acquire timeout and a 6 s connect timeout. Netty and the AWS CRT clients failed after about 2 s with the acquire timeout, so they count the time to open a new connection. The Apache clients and URLConnection failed after about 6 s with the connect timeout, so they don't. In the code, Apache and CRT use this option, and the URLConnection client never reads it. I updated the Javadoc in d1003415d9d to name the clients.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Thanks for testing all the clients. One small thing since CRT behaves like Netty, could we add the same "set it to at least the connection timeout" note to the CRT builders connectionAcquisitionTimeout docs (AwsCrtHttpClient and AwsCrtAsyncHttpClient)? Otherwise looks good to me.

@adev-code
adev-code requested a review from S-Saranya1 November 4, 2026 02:12
@adev-code
adev-code added this pull request to the merge queue Nov 4, 2026
Merged via the queue into master with commit 251f4a6 Nov 4, 2026
14 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

changelog-not-required Indicate changelog entry is not required for a specific PR no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants