926 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
927 |
|
for (Integer v1 : new Integer[] { 1, null }) |
928 |
|
{ |
929 |
– |
final AtomicInteger a = new AtomicInteger(0); |
929 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
930 |
|
if (!createIncomplete) assertTrue(f.complete(v1)); |
931 |
|
final CompletableFuture<Integer> g = m.exceptionally |
932 |
|
(f, (Throwable t) -> { |
934 |
– |
a.getAndIncrement(); |
933 |
|
threadFail("should not be called"); |
934 |
|
return null; // unreached |
935 |
|
}); |
937 |
|
|
938 |
|
checkCompletedNormally(g, v1); |
939 |
|
checkCompletedNormally(f, v1); |
942 |
– |
assertEquals(0, a.get()); |
940 |
|
}} |
941 |
|
|
942 |
|
/** |
4777 |
|
} |
4778 |
|
|
4779 |
|
/** |
4780 |
+ |
* default-implemented exceptionallyAsync action is not invoked when |
4781 |
+ |
* source completes normally, and source result is propagated |
4782 |
+ |
*/ |
4783 |
+ |
public void testDefaultExceptionallyAsync_normalCompletion() { |
4784 |
+ |
for (boolean createIncomplete : new boolean[] { true, false }) |
4785 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
4786 |
+ |
{ |
4787 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
4788 |
+ |
final DelegatedCompletionStage<Integer> d = |
4789 |
+ |
new DelegatedCompletionStage<Integer>(f); |
4790 |
+ |
if (!createIncomplete) assertTrue(f.complete(v1)); |
4791 |
+ |
final CompletionStage<Integer> g = d.exceptionallyAsync |
4792 |
+ |
((Throwable t) -> { |
4793 |
+ |
threadFail("should not be called"); |
4794 |
+ |
return null; // unreached |
4795 |
+ |
}); |
4796 |
+ |
if (createIncomplete) assertTrue(f.complete(v1)); |
4797 |
+ |
|
4798 |
+ |
checkCompletedNormally(g.toCompletableFuture(), v1); |
4799 |
+ |
}} |
4800 |
+ |
|
4801 |
+ |
/** |
4802 |
|
* default-implemented exceptionallyAsync action completes with |
4803 |
|
* function value on source exception |
4804 |
|
*/ |