Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,14 @@ public <T extends S3ClientBuilder> void applyEndpointConfigurations(T builder) {
* </pre>
*/
public <T extends S3ClientBuilder> void applyRetryConfigurations(T builder) {
ClientOverrideConfiguration.Builder configBuilder =
null != builder.overrideConfiguration()
? builder.overrideConfiguration().toBuilder()
: ClientOverrideConfiguration.builder();

builder.overrideConfiguration(
config ->
config.retryPolicy(
configBuilder
.retryPolicy(
// Use a retry strategy which will persistently retry throttled exceptions with
// exponential backoff, to give S3 a chance to autoscale.
// LEGACY mode works best here, as it will allow throttled exceptions to use all of
Expand Down Expand Up @@ -945,7 +950,8 @@ public <T extends S3ClientBuilder> void applyRetryConfigurations(T builder) {
return 5;
})
.build())
.build()));
.build())
.build());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
Expand Down Expand Up @@ -239,7 +240,7 @@ public void testS3RemoteSigningEnabled() {
}

@Test
public void s3RemoteSigningEnabledWithUserAgent() {
public void s3RemoteSigningEnabledWithUserAgentAndRetryPolicy() {
String uri = "http://localhost:12345";
Map<String, String> properties =
ImmutableMap.of(
Expand All @@ -249,6 +250,7 @@ public void s3RemoteSigningEnabledWithUserAgent() {

s3Properties.applySignerConfiguration(builder);
s3Properties.applyUserAgentConfigurations(builder);
s3Properties.applyRetryConfigurations(builder);

Optional<String> userAgent =
builder.overrideConfiguration().advancedOption(SdkAdvancedClientOption.USER_AGENT_PREFIX);
Expand All @@ -260,6 +262,9 @@ public void s3RemoteSigningEnabledWithUserAgent() {
S3V4RestSignerClient signerClient = (S3V4RestSignerClient) signer.get();
assertThat(signerClient.baseSignerUri()).isEqualTo(uri);
assertThat(signerClient.properties()).isEqualTo(properties);

Optional<RetryPolicy> retryPolicy = builder.overrideConfiguration().retryPolicy();
assertThat(retryPolicy).isPresent().get().isInstanceOf(RetryPolicy.class);
}

@Test
Expand Down