Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
fix: Removed duplicate retry logic which was causing retries on 400's…
Browse files Browse the repository at this point in the history
… and many retries on 500's (#268)
tunderwood authored Aug 13, 2020
1 parent 4a21e36 commit c657ecd
Showing 3 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -16,13 +16,6 @@

package com.nike.cerberus.aws.sts;

import static io.github.resilience4j.decorators.Decorators.ofSupplier;

import io.github.resilience4j.retry.IntervalFunction;
import io.github.resilience4j.retry.Retry;
import io.github.resilience4j.retry.RetryConfig;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@@ -31,32 +24,15 @@
public class AwsStsClient {
private final AwsStsHttpClient httpClient;

private static final RetryConfig RETRY_CONFIG =
RetryConfig.custom()
.maxAttempts(5)
.intervalFunction(
IntervalFunction.ofExponentialBackoff(Duration.of(250, ChronoUnit.MILLIS)))
.build();

private final Retry retry = Retry.of(this.getClass().getName(), RETRY_CONFIG);

@Autowired
public AwsStsClient(AwsStsHttpClient httpClient) {
this.httpClient = httpClient;
}

public GetCallerIdentityResponse getCallerIdentity(AwsStsHttpHeader header) {
return ofSupplier(
() -> {
GetCallerIdentityFullResponse response =
httpClient.execute(
header.getRegion(),
header.generateHeaders(),
GetCallerIdentityFullResponse.class);
return response.getGetCallerIdentityResponse();
})
.withRetry(retry)
.decorate()
.get();
GetCallerIdentityFullResponse response =
httpClient.execute(
header.getRegion(), header.generateHeaders(), GetCallerIdentityFullResponse.class);
return response.getGetCallerIdentityResponse();
}
}
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@ public class AwsStsHttpClient {
private static final String DEFAULT_GET_CALLER_IDENTITY_ACTION =
"Action=GetCallerIdentity&Version=2011-06-15";
private static final String DEFAULT_METHOD = "POST";
protected static final int DEFAULT_AUTH_RETRIES = 3;
private static final int DEFAULT_RETRY_INTERVAL_IN_MILLIS = 200;
protected static final int DEFAULT_AUTH_RETRIES = 5;
private static final int DEFAULT_RETRY_INTERVAL_IN_MILLIS = 250;
private static final int DEFAULT_TIMEOUT = 15;
private static final TimeUnit DEFAULT_TIMEOUT_UNIT = TimeUnit.SECONDS;
private final OkHttpClient httpClient;
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -14,6 +14,6 @@
# limitations under the License.
#

version=4.7.1
version=4.7.2
group=com.nike.cerberus
springBootVersion=2.3.2.RELEASE

0 comments on commit c657ecd

Please sign in to comment.