Skip to content

Commit

Permalink
max retry number should be atleast min retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ahanapradhan committed Mar 9, 2022
1 parent a00439e commit 526bc19
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ public Backoff(Duration maxFailureInterval, Ticker ticker, int maxTries)
public Backoff(int minTries, Duration maxFailureInterval, Ticker ticker, List<Duration> backoffDelayIntervals, int maxTries)
{
checkArgument(minTries > 0, "minTries must be at least 1");
checkArgument(maxTries > 0, "maxTries must be at least 1");
requireNonNull(maxFailureInterval, "maxFailureInterval is null");
requireNonNull(ticker, "ticker is null");
requireNonNull(backoffDelayIntervals, "backoffDelayIntervals is null");
checkArgument(!backoffDelayIntervals.isEmpty(), "backoffDelayIntervals must contain at least one entry");

this.minTries = minTries;
this.maxTries = maxTries;
this.maxTries = (minTries < maxTries) ? maxTries : minTries;
this.maxFailureIntervalNanos = maxFailureInterval.roundTo(NANOSECONDS);
this.ticker = ticker;
this.backoffDelayIntervalsNanos = backoffDelayIntervals.stream()
Expand All @@ -100,7 +99,7 @@ public Backoff(int minTries, Duration maxFailureInterval, Ticker ticker, List<Du
checkArgument(!backoffDelayIntervals.isEmpty(), "backoffDelayIntervals must contain at least one entry");

this.minTries = minTries;
this.maxTries = minTries + MAX_RETRIES; // to guaranty higher max retry value when min retry is > MAX_RETRIES
this.maxTries = (minTries < MAX_RETRIES) ? MAX_RETRIES : minTries;
this.maxFailureIntervalNanos = maxFailureInterval.roundTo(NANOSECONDS);
this.ticker = ticker;
this.backoffDelayIntervalsNanos = backoffDelayIntervals.stream()
Expand Down

0 comments on commit 526bc19

Please sign in to comment.