Starting in Java SDK v2.46.0, SDK sync clients will use Apache 5 as the default HTTP client, without the need to manually add apache5-client as a dependency. This change comes after support for Apache 5 was added in v2.41.0.
Simply add the service module to your project, and the sync client will use Apache 5 HTTP client by default:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
// Apache5HttpClient is used here
S3Client client = S3Client.create();
If you want to customize the client settings, use the Apache5HttpClient.builder() as before:
S3Client client = S3Client.builder()
.httpClientBuilder(Apache5HttpClient.builder()
.maxConnections(100)
.connectionTimeout(Duration.ofSeconds(5)))
.build();
Notable changes
- Logger name differences - Apache 5 uses different logger names than Apache 4. If you have logging configurations targeting Apache 4 logger names, you must update them. Please refer to the Apache 5 documentation, and see an example of SDK wire logging with Apache5HttpClient in the Developer Guide - Logging.
- Increase in jar size - If you explicitly depend on
apache-client, after this change the apache5-client will be also added to the classpath, resulting in a ~2.3 MB increase in bundled artifact size. To avoid the jar size increase you can exclude the apache5-client as a workaround:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<exclusions>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache5-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
</dependency>
Note that we recommend to fully migrate to use apache5-client instead of apache-client.
- Expect: 100-Continue is disabled by default - It was enabled by default in Apache 4. See PR #6828 for details. To re-enable in the Apache5 client, set the expectContinueEnabled configuration to True:
S3Client client = S3Client.builder()
.httpClientBuilder(Apache5HttpClient.builder()
.expectContinueEnabled(Boolean.TRUE))
.build();
- Network permissions needed for Java SecurityManager - Apache HttpClient 5.6 enables TCP keep-alive socket options by default (
TCP_KEEPIDLE, TCP_KEEPINTERVAL, TCP_KEEPCOUNT), which require jdk.net.NetworkPermission when a SecurityManager is active. Without these permissions, requests fail with java.security.AccessControlException: access denied. These permissions were not required for Apache 4.x. If you use SecurityManager and start to see AccessControlExceptions after the upgrade, you need to grant permission to those TCP keep-alive options, see PR #6974 for details.
Feedback
If you have questions, find a bug or have a feature request for the client to better suit your needs, please reach out to us by creating a new GitHub issue.
Starting in Java SDK
v2.46.0, SDK sync clients will use Apache 5 as the default HTTP client, without the need to manually addapache5-clientas a dependency. This change comes after support for Apache 5 was added inv2.41.0.Simply add the service module to your project, and the sync client will use Apache 5 HTTP client by default:
If you want to customize the client settings, use the Apache5HttpClient.builder() as before:
Notable changes
apache-client, after this change theapache5-clientwill be also added to the classpath, resulting in a ~2.3 MB increase in bundled artifact size. To avoid the jar size increase you can exclude theapache5-clientas a workaround:Note that we recommend to fully migrate to use
apache5-clientinstead ofapache-client.TCP_KEEPIDLE,TCP_KEEPINTERVAL,TCP_KEEPCOUNT), which requirejdk.net.NetworkPermissionwhen a SecurityManager is active. Without these permissions, requests fail withjava.security.AccessControlException: access denied. These permissions were not required for Apache 4.x. If you use SecurityManager and start to seeAccessControlExceptionsafter the upgrade, you need to grant permission to those TCP keep-alive options, see PR #6974 for details.Feedback
If you have questions, find a bug or have a feature request for the client to better suit your needs, please reach out to us by creating a new GitHub issue.