Skip to content

Commit

Permalink
Fix attempts field name in RetryDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
nezihyigitbasi authored and electrum committed May 20, 2015
1 parent f8a872d commit d5f8dbf
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -32,22 +32,22 @@ public class RetryDriver
private static final Duration DEFAULT_MAX_RETRY_TIME = Duration.valueOf("30s"); private static final Duration DEFAULT_MAX_RETRY_TIME = Duration.valueOf("30s");
private static final double DEFAULT_SCALE_FACTOR = 2.0; private static final double DEFAULT_SCALE_FACTOR = 2.0;


private final int maxRetryAttempts; private final int maxAttempts;
private final Duration minSleepTime; private final Duration minSleepTime;
private final Duration maxSleepTime; private final Duration maxSleepTime;
private final double scaleFactor; private final double scaleFactor;
private final Duration maxRetryTime; private final Duration maxRetryTime;
private final List<Class<? extends Exception>> exceptionWhiteList; private final List<Class<? extends Exception>> exceptionWhiteList;


private RetryDriver( private RetryDriver(
int maxRetryAttempts, int maxAttempts,
Duration minSleepTime, Duration minSleepTime,
Duration maxSleepTime, Duration maxSleepTime,
double scaleFactor, double scaleFactor,
Duration maxRetryTime, Duration maxRetryTime,
List<Class<? extends Exception>> exceptionWhiteList) List<Class<? extends Exception>> exceptionWhiteList)
{ {
this.maxRetryAttempts = maxRetryAttempts; this.maxAttempts = maxAttempts;
this.minSleepTime = minSleepTime; this.minSleepTime = minSleepTime;
this.maxSleepTime = maxSleepTime; this.maxSleepTime = maxSleepTime;
this.scaleFactor = scaleFactor; this.scaleFactor = scaleFactor;
Expand Down Expand Up @@ -77,7 +77,7 @@ public final RetryDriver maxAttempts(int maxAttempts)


public final RetryDriver exponentialBackoff(Duration minSleepTime, Duration maxSleepTime, Duration maxRetryTime, double scaleFactor) public final RetryDriver exponentialBackoff(Duration minSleepTime, Duration maxSleepTime, Duration maxRetryTime, double scaleFactor)
{ {
return new RetryDriver(maxRetryAttempts, minSleepTime, maxSleepTime, scaleFactor, maxRetryTime, exceptionWhiteList); return new RetryDriver(maxAttempts, minSleepTime, maxSleepTime, scaleFactor, maxRetryTime, exceptionWhiteList);
} }


@SafeVarargs @SafeVarargs
Expand All @@ -89,7 +89,7 @@ public final RetryDriver stopOn(Class<? extends Exception>... classes)
.addAll(Arrays.asList(classes)) .addAll(Arrays.asList(classes))
.build(); .build();


return new RetryDriver(maxRetryAttempts, minSleepTime, maxSleepTime, scaleFactor, maxRetryTime, exceptions); return new RetryDriver(maxAttempts, minSleepTime, maxSleepTime, scaleFactor, maxRetryTime, exceptions);
} }


public RetryDriver stopOnIllegalExceptions() public RetryDriver stopOnIllegalExceptions()
Expand All @@ -116,7 +116,7 @@ public <V> V run(String callableName, Callable<V> callable)
throw e; throw e;
} }
} }
if (attempt >= maxRetryAttempts || Duration.nanosSince(startTime).compareTo(maxRetryTime) >= 0) { if (attempt >= maxAttempts || Duration.nanosSince(startTime).compareTo(maxRetryTime) >= 0) {
throw e; throw e;
} }
log.debug("Failed on executing %s with attempt %d, will retry. Exception: %s", callableName, attempt, e.getMessage()); log.debug("Failed on executing %s with attempt %d, will retry. Exception: %s", callableName, attempt, e.getMessage());
Expand Down

0 comments on commit d5f8dbf

Please sign in to comment.