@Test public void shouldStopRetryingWhenFutureIsCancelled() { final RuntimeException error = new RuntimeException("No way"); final SafeFuture<ScheduledDuties> delegateResponse = new SafeFuture<>(); when(delegate.loadDutiesForEpoch(ONE)).thenReturn(delegateResponse); final SafeFuture<ScheduledDuties> result = dutyLoader.loadDutiesForEpoch(ONE); verify(delegate).loadDutiesForEpoch(ONE); assertThat(result).isNotDone(); result.cancel(false); delegateResponse.completeExceptionally(error); assertThat(asyncRunner.hasDelayedActions()).isFalse(); verifyNoMoreInteractions(delegate); }
@Override public SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch) { final SafeFuture<ScheduledDuties> duties = new SafeFuture<>(); requestDuties(epoch, duties).propagateTo(duties); return duties; }
RetryingDutyLoader implements DutyLoader { @Override public SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch) { final SafeFuture<ScheduledDuties> duties = new SafeFuture<>(); requestDuties(epoch, duties).propagateTo(duties); return duties; } }
RetryingDutyLoader implements DutyLoader { @Override public SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch) { final SafeFuture<ScheduledDuties> duties = new SafeFuture<>(); requestDuties(epoch, duties).propagateTo(duties); return duties; } RetryingDutyLoader(final AsyncRunner asyncRunner, final DutyLoader delegate); }
RetryingDutyLoader implements DutyLoader { @Override public SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch) { final SafeFuture<ScheduledDuties> duties = new SafeFuture<>(); requestDuties(epoch, duties).propagateTo(duties); return duties; } RetryingDutyLoader(final AsyncRunner asyncRunner, final DutyLoader delegate); @Override SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch); }
RetryingDutyLoader implements DutyLoader { @Override public SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch) { final SafeFuture<ScheduledDuties> duties = new SafeFuture<>(); requestDuties(epoch, duties).propagateTo(duties); return duties; } RetryingDutyLoader(final AsyncRunner asyncRunner, final DutyLoader delegate); @Override SafeFuture<ScheduledDuties> loadDutiesForEpoch(final UInt64 epoch);  }