use of org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture in project flink by apache.
the class FutureUtilsTest method testConjunctFutureFailureOnFirst.
@Test
public void testConjunctFutureFailureOnFirst() throws Exception {
CompletableFuture<Object> future1 = new FlinkCompletableFuture<>();
CompletableFuture<Object> future2 = new FlinkCompletableFuture<>();
CompletableFuture<Object> future3 = new FlinkCompletableFuture<>();
CompletableFuture<Object> future4 = new FlinkCompletableFuture<>();
// build the conjunct future
ConjunctFuture result = FutureUtils.combineAll(Arrays.asList(future1, future2, future3, future4));
Future<Void> resultMapped = result.thenAccept(new AcceptFunction<Void>() {
@Override
public void accept(Void value) {
}
});
assertEquals(4, result.getNumFuturesTotal());
assertEquals(0, result.getNumFuturesCompleted());
assertFalse(result.isDone());
assertFalse(resultMapped.isDone());
future2.completeExceptionally(new IOException());
assertEquals(0, result.getNumFuturesCompleted());
assertTrue(result.isDone());
assertTrue(resultMapped.isDone());
try {
result.get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof IOException);
}
try {
resultMapped.get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof IOException);
}
}
Aggregations