From 1ce1dcbdd0912d1f3f17cc69ef6a5139041334f6 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Tue, 11 Jun 2024 16:35:35 +0200 Subject: [PATCH] make UMAPI request backoff really exponential --- .../biz/netcentric/cq/tools/actool/ims/IMSUserManagement.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/IMSUserManagement.java b/accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/IMSUserManagement.java index f6ec9370..d4ff93bf 100644 --- a/accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/IMSUserManagement.java +++ b/accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/IMSUserManagement.java @@ -110,6 +110,7 @@ public class IMSUserManagement implements ExternalGroupManagement { * */ static final class TooManyRequestsRetryStrategy implements ServiceUnavailableRetryStrategy { + private static final double DEFAULT_MULTIPLIER = 1.5; // increases each time by 50% private final int maxRetryCount; private final int defaultRetryDelayInSeconds; private long retryDelayInMilliseconds; @@ -134,7 +135,7 @@ public boolean retryRequest(HttpResponse response, int executionCount, HttpConte LOG.info("Received 429 status with Retry-After header {}", retryAfterHeader.getValue()); } // make it exponential because the retry-after is unreliable (particularly with multiple requests in parallel) - retryDelayInMilliseconds *= executionCount; + retryDelayInMilliseconds *= Math.pow(DEFAULT_MULTIPLIER, executionCount); // always add some jitter between 0 and default delay in seconds long jitter= random.nextInt(defaultRetryDelayInSeconds) * 1000l; retryDelayInMilliseconds += jitter;