in libs/utils/src/main/java/co/elastic/gradle/utils/RetryUtils.java [68:96]
private T execute(int attempts) {
if (attempts == 0) {
this.initialDelay.ifPresent(delay -> {
try {
Thread.sleep(delay);
}
catch (InterruptedException e) {
//may be trying to shut-down. End early.
}
});
}
try {
return action.get();
} catch (Exception e) {
maxAttempt
.filter(maxAttempt -> attempts >= maxAttempt - 1)
.ifPresent( it -> { throw e; } );
retryErrorConsumer.ifPresent(onError -> onError.accept(e));
scheduler.ifPresent(scheduler -> {
try {
Thread.sleep(scheduler.deferTime(attempts));
} catch (InterruptedException interruptedException) {
throw new RetryException("Error while waiting during retry "+ attempts, interruptedException);
}
});
return execute(attempts + 1);
}
}