-
Notifications
You must be signed in to change notification settings - Fork 964
Don't special case 0 TTL in Apache 5 #6606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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()) { |
There was a problem hiding this comment.
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.
This reverts commit 86a120a.
...ents/apache5-client/src/main/java/software/amazon/awssdk/http/apache5/Apache5HttpClient.java
Outdated
Show resolved
Hide resolved
...ents/apache5-client/src/test/java/software/amazon/awssdk/http/apache5/ConnectionTtlTest.java
Show resolved
Hide resolved
|
|
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. |



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: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-L93For Netty,
if (configuration.connectionTtlMillis() > 0) {
pipeline.addLast(new OldConnectionReaperHandler(configuration.connectionTtlMillis()));
}
OldConnectionReaperHandleris only used when the TTL value > 0, otherwise the handler is not added to the channel's pipeline:aws-sdk-java-v2/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/ChannelPipelineInitializer.java
Lines 213 to 216 in 90f17ab
CRT and URLConnection client does not support this configuration.Motivation and Context
Modifications
Testing
New unit tests to verify behavior.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License