jdk Udiff test/java/util/concurrent/CompletableFuture/Basic.java (original) (raw)
@@ -502,11 +502,11 @@ check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
try { check(cf3.join() == 2); } catch (CompletionException x) { pass(); } check(cf3.isDone()); check(cf1.isDone() || cf2.isDone()); cf1 = supplyAsync(() -> 1); cf2 = supplyAsync(() -> { throw new RuntimeException(); });
@@ -603,23 +603,27 @@
before = atomicInt.get();
cf1 = runAsync(() -> { throw new RuntimeException(); });
cf2 = runAsync(() -> { });
cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); });
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
} catch (CompletionException x) { pass(); } check(cf3.isDone()); check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1)); before = atomicInt.get(); cf1 = runAsync(() -> { }); cf2 = runAsync(() -> { throw new RuntimeException(); }); cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
} catch (CompletionException x) { pass(); } check(cf3.isDone()); check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1)); before = atomicInt.get(); cf1 = runAsync(() -> { throw new RuntimeException(); }); cf2 = runAsync(() -> { throw new RuntimeException(); }); cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);