Skip to content

Conversation

@dagnir
Copy link
Contributor

@dagnir dagnir commented Dec 2, 2025

After discussing with @zoewangg we don't want to update the default because it may affect external implementations of SdkHttpClient/SdkAsyncHttpClient.

Changing the default value locally to the Apache 5 client instead. No need for this any longer. Can simply ignore non-positive values.


This commit updates the definition of the CONNECTION_TIME_TO_LIVE (TTL) so that non-positive values indicate an infinite TTL. The reason for this is that in contrast to Apache 4.x, Apache 5.x uses 0 to indicate immediate expiry. This updated definition allows us to use a new default value of -1 across all supported HTTP clients to indicate an infinite TTL.

Note that in practice, this is already the case, as all clients other than the Apache 5.x client treat non-positive values as infinite:

Motivation and Context

Modifications

Testing

New unit tests to verify behavior.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

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

This commit updates the definition of the CONNECTION_TIME_TO_LIVE (TTL)
so that non-positive values indicate an infinite TTL. The reason for
this is that in contrast to Apache 4.x, Apache 5.x uses 0 to indicate
immediate expiry. This updated definition allows us to use a new default
value of -1 across all supported HTTP clients to indicate an infinite
TTL.

Note that in practice, this is already the case, as all clients other
than the Apache 5.x client treat non-positive values as infinite:

 - For Apache 4.x, value of <= 0 is treated as infinite: https://github.com/apache/httpcomponents-core/blob/a5c117028b7c620974304636d52f06f172f1d08b/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java#L87-L93
 - For Netty, `OldConnectionReaperHandler` is only used when the TTL
   value > 0, otherwise the handler is not added to the channel's
   pipeline:
   https://github.com/aws/aws-sdk-java-v2/blob/90f17ab300e27bee5367e4eff30b49bfa1f06af0/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/ChannelPipelineInitializer.java#L213-L216
 - CRT and URLConnection client does not support this configuration.
Duration connectionTtl = standardOptions.get(SdkHttpConfigurationOption.CONNECTION_TIME_TO_LIVE);
if (!connectionTtl.isZero()) {
// Skip TTL=0 to maintain backward compatibility (infinite in 4.x vs immediate expiration in 5.x)
if (!connectionTtl.isNegative()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: using isNegative() rather than isPositive() allows customer to have access to immediate expiry by directly setting Duration.ZERO. Should we allow this?

Shadow the global default CONNECTION_TIME_TO_LIVE value of 0 to -1
within the Apache 5 client instead of special casing the 0 value when
building the connection config.
@dagnir dagnir changed the title Define infinite TTL as <= 0 Don't special case 0 TTL in Apache 5 Dec 3, 2025
@dagnir dagnir marked this pull request as ready for review December 3, 2025 00:22
@dagnir dagnir requested a review from a team as a code owner December 3, 2025 00:22
@dagnir dagnir 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 Dec 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 3, 2025

@dagnir dagnir added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@dagnir dagnir added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@dagnir dagnir added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@dagnir dagnir added this pull request to the merge queue Dec 4, 2025
Merged via the queue into master with commit 17e9a4b Dec 4, 2025
50 of 52 checks passed
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

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 Dec 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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