From 5f587f5fb960b0602e6bb48259ddf3ff43a5c6ea Mon Sep 17 00:00:00 2001 From: BLAKE JANELLE Date: Fri, 21 Jun 2019 11:47:07 -0400 Subject: [PATCH] #80 adding retry policy to avoid API rate limiting errors. --- .../herman/aws/credentials/BambooCredentialsHandler.java | 5 ++++- .../herman/aws/credentials/CredentialsHandler.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/libertymutualgroup/herman/aws/credentials/BambooCredentialsHandler.java b/src/main/java/com/libertymutualgroup/herman/aws/credentials/BambooCredentialsHandler.java index 71c55df..74204b1 100644 --- a/src/main/java/com/libertymutualgroup/herman/aws/credentials/BambooCredentialsHandler.java +++ b/src/main/java/com/libertymutualgroup/herman/aws/credentials/BambooCredentialsHandler.java @@ -19,6 +19,7 @@ import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicSessionCredentials; import com.amazonaws.auth.InstanceProfileCredentialsProvider; +import com.amazonaws.retry.PredefinedRetryPolicies; import com.atlassian.bamboo.task.CommonTaskContext; import com.atlassian.bamboo.variable.VariableContext; import com.atlassian.bamboo.variable.VariableDefinitionContext; @@ -58,7 +59,9 @@ public static AWSCredentials getCredentials(CommonTaskContext context) { } public static ClientConfiguration getConfiguration() { - return new ClientConfiguration().withMaxErrorRetry(10); + return new ClientConfiguration() + .withMaxErrorRetry(10) + .withRetryPolicy(PredefinedRetryPolicies.getDefaultRetryPolicyWithCustomMaxRetries(10)); } private static String lookupVar(String key, CommonTaskContext context) { diff --git a/src/main/java/com/libertymutualgroup/herman/aws/credentials/CredentialsHandler.java b/src/main/java/com/libertymutualgroup/herman/aws/credentials/CredentialsHandler.java index 96bab21..3b3bca7 100644 --- a/src/main/java/com/libertymutualgroup/herman/aws/credentials/CredentialsHandler.java +++ b/src/main/java/com/libertymutualgroup/herman/aws/credentials/CredentialsHandler.java @@ -18,6 +18,7 @@ import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; +import com.amazonaws.retry.PredefinedRetryPolicies; public class CredentialsHandler { @@ -35,6 +36,8 @@ public static AWSCredentials getCredentials() { } public static ClientConfiguration getConfiguration() { - return new ClientConfiguration().withMaxErrorRetry(10); + return new ClientConfiguration() + .withMaxErrorRetry(10) + .withRetryPolicy(PredefinedRetryPolicies.getDefaultRetryPolicyWithCustomMaxRetries(10)); } }