Setting the defaults for the BackoffPolicy in the builder constructor

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
This commit is contained in:
Max Lambrecht 2020-05-01 08:44:46 -03:00
parent 30c0ddb5e2
commit b0bac0c29a
1 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ public class BackoffPolicy {
/**
* Retry indefinitely, default behavior
*/
public static final int UNLIMITED_RETRIES = -1;
public static final int UNLIMITED_RETRIES = 0;
private static final int BACKOFF_MULTIPLIER = 2;
@ -45,10 +45,10 @@ public class BackoffPolicy {
@Builder
public BackoffPolicy(Duration initialDelay, Duration maxDelay, int maxRetries, UnaryOperator<Duration> backoffFunction) {
this.initialDelay = initialDelay;
this.maxDelay = maxDelay;
this.initialDelay = initialDelay != null ? initialDelay : Duration.ofSeconds(1);
this.maxDelay = maxDelay != null ? maxDelay : Duration.ofSeconds(60);
this.maxRetries = maxRetries;
this.backoffFunction = backoffFunction;
this.backoffFunction = backoffFunction != null ? backoffFunction : d -> d.multipliedBy(BACKOFF_MULTIPLIER);
}
/**