}
@Test
- void composeWithRetry1() throws InterruptedException {
+ void composeWithRetry1() {
AtomicInteger visitCount = new AtomicInteger();
CompletableFuture<String> composedFuture = new CompletableFuture<>();
Future<String> retryFuture = RetryFuture.composeWithRetry(() -> {
if (!latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
fail("Timeout while waiting for latch");
}
- Thread.sleep(1);
- retryFuture.cancel(false);
-
- assertTrue(composedFuture.isCancelled());
- } catch (InterruptedException e) {
+ Future<Boolean> future = scheduler.submit(() -> {
+ retryFuture.cancel(false);
+ return composedFuture.isCancelled();
+ });
+ assertTrue(future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
fail(e);
}
assertEquals(2, visitCount.get());