Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public boolean advance() throws IOException {

private boolean advanceWithBackoff() throws IOException {
// Try reading from the source with exponential backoff
BackOff backoff = new IntervalBoundedExponentialBackOff(10000, 10);
BackOff backoff = new IntervalBoundedExponentialBackOff(10000L, 10L);
long nextSleep = backoff.nextBackOffMillis();
while (nextSleep != BackOff.STOP) {
if (endTime != null && Instant.now().isAfter(endTime)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public class IntervalBoundedExponentialBackOffTest {
public void testUsingInvalidInitialInterval() throws Exception {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Initial interval must be greater than zero.");
new IntervalBoundedExponentialBackOff(1000, 0L);
new IntervalBoundedExponentialBackOff(1000L, 0L);
}

@Test
public void testUsingInvalidMaximumInterval() throws Exception {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Maximum interval must be greater than zero.");
new IntervalBoundedExponentialBackOff(-1, 10L);
new IntervalBoundedExponentialBackOff(-1L, 10L);
}

@Test
public void testThatcertainNumberOfAttemptsReachesMaxInterval() throws Exception {
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000, 500);
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000L, 500);
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(249L), lessThan(751L)));
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(374L), lessThan(1126L)));
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(500L),
Expand All @@ -70,7 +70,7 @@ public void testThatcertainNumberOfAttemptsReachesMaxInterval() throws Exception

@Test
public void testThatResettingAllowsReuse() throws Exception {
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000, 500);
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000L, 500);
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(249L), lessThan(751L)));
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(374L), lessThan(1126L)));
assertThat(backOff.nextBackOffMillis(), allOf(greaterThanOrEqualTo(500L),
Expand All @@ -88,7 +88,7 @@ public void testThatResettingAllowsReuse() throws Exception {

@Test
public void testAtMaxInterval() throws Exception {
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000, 500);
IntervalBoundedExponentialBackOff backOff = new IntervalBoundedExponentialBackOff(1000L, 500);
assertFalse(backOff.atMaxInterval());
backOff.nextBackOffMillis();
assertFalse(backOff.atMaxInterval());
Expand Down