@Test public void testSleeping() throws Exception { ExponentialBackoffRetryHandler handler = new ExponentialBackoffRetryHandler(6, ofMillis(10), ofMillis(200), sleeper); handler.retryRequest(mock(IOException.class), 2); ArgumentCaptor<Duration> durationArgumentCaptor = ArgumentCaptor.forClass(Duration.class); verify(sleeper).sleep(durationArgumentCaptor.capture()); assertThat(durationArgumentCaptor.getValue(), is(both(greaterThan(ofMillis(9L))).and(lessThan(ofMillis(31L))))); }
@Override public boolean retryRequest(IOException exception, int executionCount) { if (executionCount <= maxRetries) { Duration sleepTime = getSleepTime(executionCount); return sleeper.sleep(sleepTime); } else { return false; } }
ExponentialBackoffRetryHandler implements RetryHandler { @Override public boolean retryRequest(IOException exception, int executionCount) { if (executionCount <= maxRetries) { Duration sleepTime = getSleepTime(executionCount); return sleeper.sleep(sleepTime); } else { return false; } } }
ExponentialBackoffRetryHandler implements RetryHandler { @Override public boolean retryRequest(IOException exception, int executionCount) { if (executionCount <= maxRetries) { Duration sleepTime = getSleepTime(executionCount); return sleeper.sleep(sleepTime); } else { return false; } }  }
ExponentialBackoffRetryHandler implements RetryHandler { @Override public boolean retryRequest(IOException exception, int executionCount) { if (executionCount <= maxRetries) { Duration sleepTime = getSleepTime(executionCount); return sleeper.sleep(sleepTime); } else { return false; } }  @Override boolean retryRequest(IOException exception, int executionCount); }
ExponentialBackoffRetryHandler implements RetryHandler { @Override public boolean retryRequest(IOException exception, int executionCount) { if (executionCount <= maxRetries) { Duration sleepTime = getSleepTime(executionCount); return sleeper.sleep(sleepTime); } else { return false; } }  @Override boolean retryRequest(IOException exception, int executionCount);  }