@Test public void forFirstBackOffAlwaysReturnsZero() { assertThat(getDefaultRetryExecution().nextDelay().get()).isEqualTo(0); }
public Optional<Long> nextDelay() { if (lastAttemptIndex == 0) { lastAttemptIndex++; return Optional.of(0L); } if (genericRetry.getMaxAttempts() > -1 && lastAttemptIndex >= genericRetry.getMaxAttempts()) { return Optional.empty(); } if (lastAttemptIndex > 1) { currentInterval = (long) (currentInterval * genericRetry.getIntervalMultiplier()); if (genericRetry.getMaxInterval() > -1 && currentInterval > genericRetry.getMaxInterval()) { currentInterval = genericRetry.getMaxInterval(); } } lastAttemptIndex++; return Optional.of(currentInterval); }
GenericRetryExecution implements RetryExecution { public Optional<Long> nextDelay() { if (lastAttemptIndex == 0) { lastAttemptIndex++; return Optional.of(0L); } if (genericRetry.getMaxAttempts() > -1 && lastAttemptIndex >= genericRetry.getMaxAttempts()) { return Optional.empty(); } if (lastAttemptIndex > 1) { currentInterval = (long) (currentInterval * genericRetry.getIntervalMultiplier()); if (genericRetry.getMaxInterval() > -1 && currentInterval > genericRetry.getMaxInterval()) { currentInterval = genericRetry.getMaxInterval(); } } lastAttemptIndex++; return Optional.of(currentInterval); } }
GenericRetryExecution implements RetryExecution { public Optional<Long> nextDelay() { if (lastAttemptIndex == 0) { lastAttemptIndex++; return Optional.of(0L); } if (genericRetry.getMaxAttempts() > -1 && lastAttemptIndex >= genericRetry.getMaxAttempts()) { return Optional.empty(); } if (lastAttemptIndex > 1) { currentInterval = (long) (currentInterval * genericRetry.getIntervalMultiplier()); if (genericRetry.getMaxInterval() > -1 && currentInterval > genericRetry.getMaxInterval()) { currentInterval = genericRetry.getMaxInterval(); } } lastAttemptIndex++; return Optional.of(currentInterval); } GenericRetryExecution(GenericRetry genericRetry); }
GenericRetryExecution implements RetryExecution { public Optional<Long> nextDelay() { if (lastAttemptIndex == 0) { lastAttemptIndex++; return Optional.of(0L); } if (genericRetry.getMaxAttempts() > -1 && lastAttemptIndex >= genericRetry.getMaxAttempts()) { return Optional.empty(); } if (lastAttemptIndex > 1) { currentInterval = (long) (currentInterval * genericRetry.getIntervalMultiplier()); if (genericRetry.getMaxInterval() > -1 && currentInterval > genericRetry.getMaxInterval()) { currentInterval = genericRetry.getMaxInterval(); } } lastAttemptIndex++; return Optional.of(currentInterval); } GenericRetryExecution(GenericRetry genericRetry); Optional<Long> nextDelay(); @Override boolean isLastExecution(); }
GenericRetryExecution implements RetryExecution { public Optional<Long> nextDelay() { if (lastAttemptIndex == 0) { lastAttemptIndex++; return Optional.of(0L); } if (genericRetry.getMaxAttempts() > -1 && lastAttemptIndex >= genericRetry.getMaxAttempts()) { return Optional.empty(); } if (lastAttemptIndex > 1) { currentInterval = (long) (currentInterval * genericRetry.getIntervalMultiplier()); if (genericRetry.getMaxInterval() > -1 && currentInterval > genericRetry.getMaxInterval()) { currentInterval = genericRetry.getMaxInterval(); } } lastAttemptIndex++; return Optional.of(currentInterval); } GenericRetryExecution(GenericRetry genericRetry); Optional<Long> nextDelay(); @Override boolean isLastExecution();  }