75 |
|
try { |
76 |
|
f.join(); |
77 |
|
shouldThrow(); |
78 |
< |
} catch (Throwable ex) { |
79 |
< |
assertTrue(ex instanceof CompletionException && |
80 |
< |
((CompletionException)ex).getCause() instanceof CFException); |
78 |
> |
} catch (CompletionException success) { |
79 |
> |
assertTrue(success.getCause() instanceof CFException); |
80 |
|
} |
81 |
|
try { |
82 |
|
f.getNow(null); |
83 |
|
shouldThrow(); |
84 |
< |
} catch (Throwable ex) { |
85 |
< |
assertTrue(ex instanceof CompletionException && |
87 |
< |
((CompletionException)ex).getCause() instanceof CFException); |
84 |
> |
} catch (CompletionException success) { |
85 |
> |
assertTrue(success.getCause() instanceof CFException); |
86 |
|
} |
87 |
|
try { |
88 |
|
f.get(); |
89 |
|
shouldThrow(); |
90 |
< |
} catch (Throwable ex) { |
91 |
< |
assertTrue(ex instanceof ExecutionException && |
92 |
< |
((ExecutionException)ex).getCause() instanceof CFException); |
95 |
< |
} |
90 |
> |
} catch (ExecutionException success) { |
91 |
> |
assertTrue(success.getCause() instanceof CFException); |
92 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
93 |
|
try { |
94 |
|
f.get(0L, SECONDS); |
95 |
|
shouldThrow(); |
96 |
< |
} catch (Throwable ex) { |
97 |
< |
assertTrue(ex instanceof ExecutionException && |
98 |
< |
((ExecutionException)ex).getCause() instanceof CFException); |
102 |
< |
} |
96 |
> |
} catch (ExecutionException success) { |
97 |
> |
assertTrue(success.getCause() instanceof CFException); |
98 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
99 |
|
assertTrue(f.isDone()); |
100 |
|
assertFalse(f.isCancelled()); |
101 |
|
} |
104 |
|
try { |
105 |
|
f.join(); |
106 |
|
shouldThrow(); |
107 |
< |
} catch (Throwable ex) { |
112 |
< |
assertTrue(ex instanceof CancellationException); |
113 |
< |
} |
107 |
> |
} catch (CancellationException success) {} |
108 |
|
try { |
109 |
|
f.getNow(null); |
110 |
|
shouldThrow(); |
111 |
< |
} catch (Throwable ex) { |
118 |
< |
assertTrue(ex instanceof CancellationException); |
119 |
< |
} |
111 |
> |
} catch (CancellationException success) {} |
112 |
|
try { |
113 |
|
f.get(); |
114 |
|
shouldThrow(); |
115 |
< |
} catch (Throwable ex) { |
116 |
< |
assertTrue(ex instanceof CancellationException); |
125 |
< |
} |
115 |
> |
} catch (CancellationException success) { |
116 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
117 |
|
try { |
118 |
|
f.get(0L, SECONDS); |
119 |
|
shouldThrow(); |
120 |
< |
} catch (Throwable ex) { |
121 |
< |
assertTrue(ex instanceof CancellationException); |
131 |
< |
} |
120 |
> |
} catch (CancellationException success) { |
121 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
122 |
|
assertTrue(f.isDone()); |
123 |
|
assertTrue(f.isCancelled()); |
124 |
|
} |
127 |
|
try { |
128 |
|
f.join(); |
129 |
|
shouldThrow(); |
130 |
< |
} catch (Throwable ex) { |
131 |
< |
assertTrue(ex instanceof CompletionException && |
142 |
< |
((CompletionException)ex).getCause() instanceof CancellationException); |
130 |
> |
} catch (CompletionException success) { |
131 |
> |
assertTrue(success.getCause() instanceof CancellationException); |
132 |
|
} |
133 |
|
try { |
134 |
|
f.getNow(null); |
135 |
|
shouldThrow(); |
136 |
< |
} catch (Throwable ex) { |
137 |
< |
assertTrue(ex instanceof CompletionException && |
149 |
< |
((CompletionException)ex).getCause() instanceof CancellationException); |
136 |
> |
} catch (CompletionException success) { |
137 |
> |
assertTrue(success.getCause() instanceof CancellationException); |
138 |
|
} |
139 |
|
try { |
140 |
|
f.get(); |
141 |
|
shouldThrow(); |
142 |
< |
} catch (Throwable ex) { |
143 |
< |
assertTrue(ex instanceof ExecutionException && |
144 |
< |
((ExecutionException)ex).getCause() instanceof CancellationException); |
157 |
< |
} |
142 |
> |
} catch (ExecutionException success) { |
143 |
> |
assertTrue(success.getCause() instanceof CancellationException); |
144 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
145 |
|
try { |
146 |
|
f.get(0L, SECONDS); |
147 |
|
shouldThrow(); |
148 |
< |
} catch (Throwable ex) { |
149 |
< |
assertTrue(ex instanceof ExecutionException && |
150 |
< |
((ExecutionException)ex).getCause() instanceof CancellationException); |
164 |
< |
} |
148 |
> |
} catch (ExecutionException success) { |
149 |
> |
assertTrue(success.getCause() instanceof CancellationException); |
150 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
151 |
|
assertTrue(f.isDone()); |
152 |
|
assertFalse(f.isCancelled()); |
153 |
|
} |
235 |
|
f.obtrudeException(new CFException()); |
236 |
|
checkCompletedWithWrappedCFException(f); |
237 |
|
} |
238 |
< |
|
238 |
> |
|
239 |
|
/** |
240 |
|
* getNumberOfDependents returns number of dependent tasks |
241 |
|
*/ |
271 |
|
assertTrue(f.toString().contains("[Completed exceptionally]")); |
272 |
|
} |
273 |
|
|
274 |
< |
static final Supplier<Integer> supplyOne = |
274 |
> |
static final Supplier<Integer> supplyOne = |
275 |
|
() -> Integer.valueOf(1); |
276 |
< |
static final Function<Integer, Integer> inc = |
276 |
> |
static final Function<Integer, Integer> inc = |
277 |
|
(Integer x) -> Integer.valueOf(x.intValue() + 1); |
278 |
< |
static final BiFunction<Integer, Integer, Integer> add = |
278 |
> |
static final BiFunction<Integer, Integer, Integer> add = |
279 |
|
(Integer x, Integer y) -> Integer.valueOf(x.intValue() + y.intValue()); |
280 |
|
static final class IncAction implements Consumer<Integer> { |
281 |
|
int value; |
283 |
|
} |
284 |
|
static final class AddAction implements BiConsumer<Integer, Integer> { |
285 |
|
int value; |
286 |
< |
public void accept(Integer x, Integer y) { |
287 |
< |
value = x.intValue() + y.intValue(); |
286 |
> |
public void accept(Integer x, Integer y) { |
287 |
> |
value = x.intValue() + y.intValue(); |
288 |
|
} |
289 |
|
} |
290 |
|
static final class Noop implements Runnable { |
331 |
|
ran = true; throw new CFException(); |
332 |
|
} |
333 |
|
} |
334 |
< |
|
334 |
> |
|
335 |
|
// Used for explicit executor tests |
336 |
|
static final class ThreadExecutor implements Executor { |
337 |
|
public void execute(Runnable r) { |
344 |
|
} |
345 |
|
|
346 |
|
static final class IntegerHandler implements BiFunction<Integer, Throwable, Integer> { |
347 |
< |
public Integer apply(Integer x, Throwable t) { |
347 |
> |
public Integer apply(Integer x, Throwable t) { |
348 |
|
return (t == null) ? two : three; |
349 |
|
} |
350 |
|
} |
442 |
|
assertTrue(r.ran); |
443 |
|
} |
444 |
|
|
445 |
< |
// seq conmpletion methods |
446 |
< |
|
445 |
> |
// seq completion methods |
446 |
> |
|
447 |
|
/** |
448 |
|
* thenRun result completes normally after normal completion of source |
449 |
|
*/ |
1112 |
|
try { |
1113 |
|
g.join(); |
1114 |
|
shouldThrow(); |
1115 |
< |
} catch(Exception ok) { |
1115 |
> |
} catch (Exception ok) { |
1116 |
|
} |
1117 |
|
checkCompletedWithWrappedCFException(g); |
1118 |
|
} |
1127 |
|
f.complete(null); |
1128 |
|
checkCompletedWithWrappedCFException(g); |
1129 |
|
} |
1130 |
< |
|
1130 |
> |
|
1131 |
|
/** |
1132 |
|
* thenRunAsync result completes exceptionally if source cancelled |
1133 |
|
*/ |
1170 |
|
f.complete(null); |
1171 |
|
checkCompletedWithWrappedCFException(g); |
1172 |
|
} |
1173 |
< |
|
1173 |
> |
|
1174 |
|
/** |
1175 |
|
* thenApplyAsync result completes exceptionally if source cancelled |
1176 |
|
*/ |
1216 |
|
f.complete(null); |
1217 |
|
checkCompletedWithWrappedCFException(g); |
1218 |
|
} |
1219 |
< |
|
1219 |
> |
|
1220 |
|
/** |
1221 |
|
* thenAcceptAsync result completes exceptionally if source cancelled |
1222 |
|
*/ |
1274 |
|
f2.complete(two); |
1275 |
|
checkCompletedWithWrappedCFException(g); |
1276 |
|
} |
1277 |
< |
|
1277 |
> |
|
1278 |
|
/** |
1279 |
|
* thenCombineAsync result completes exceptionally if either source cancelled |
1280 |
|
*/ |
1285 |
|
assertTrue(f.cancel(true)); |
1286 |
|
f2.complete(two); |
1287 |
|
checkCompletedWithWrappedCancellationException(g); |
1288 |
< |
|
1288 |
> |
|
1289 |
|
f = new CompletableFuture<Integer>(); |
1290 |
|
f2 = new CompletableFuture<Integer>(); |
1291 |
|
g = f.thenCombineAsync(f2, add); |
1339 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1340 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1341 |
|
FailingBiConsumer r = new FailingBiConsumer(); |
1342 |
< |
CompletableFuture<Void> g = f.thenAcceptBothAsync(f2, r); |
1342 |
> |
CompletableFuture<Void> g = f.thenAcceptBothAsync(f2, r); |
1343 |
|
f.complete(one); |
1344 |
|
checkIncomplete(g); |
1345 |
|
f2.complete(two); |
1346 |
|
checkCompletedWithWrappedCFException(g); |
1347 |
|
} |
1348 |
< |
|
1348 |
> |
|
1349 |
|
/** |
1350 |
|
* thenAcceptBothAsync result completes exceptionally if either source cancelled |
1351 |
|
*/ |
1357 |
|
assertTrue(f.cancel(true)); |
1358 |
|
f2.complete(two); |
1359 |
|
checkCompletedWithWrappedCancellationException(g); |
1360 |
< |
|
1360 |
> |
|
1361 |
|
r = new AddAction(); |
1362 |
|
f = new CompletableFuture<Integer>(); |
1363 |
|
f2 = new CompletableFuture<Integer>(); |
1412 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1413 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1414 |
|
FailingNoop r = new FailingNoop(); |
1415 |
< |
CompletableFuture<Void> g = f.runAfterBothAsync(f2, r); |
1415 |
> |
CompletableFuture<Void> g = f.runAfterBothAsync(f2, r); |
1416 |
|
f.complete(one); |
1417 |
|
checkIncomplete(g); |
1418 |
|
f2.complete(two); |
1419 |
|
checkCompletedWithWrappedCFException(g); |
1420 |
|
} |
1421 |
< |
|
1421 |
> |
|
1422 |
|
/** |
1423 |
|
* runAfterBothAsync result completes exceptionally if either source cancelled |
1424 |
|
*/ |
1430 |
|
assertTrue(f.cancel(true)); |
1431 |
|
f2.complete(two); |
1432 |
|
checkCompletedWithWrappedCancellationException(g); |
1433 |
< |
|
1433 |
> |
|
1434 |
|
r = new Noop(); |
1435 |
|
f = new CompletableFuture<Integer>(); |
1436 |
|
f2 = new CompletableFuture<Integer>(); |
1484 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1485 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1486 |
|
FailingFunction r = new FailingFunction(); |
1487 |
< |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r); |
1487 |
> |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r); |
1488 |
|
f.complete(one); |
1489 |
|
checkCompletedWithWrappedCFException(g); |
1490 |
|
} |
1491 |
< |
|
1491 |
> |
|
1492 |
|
/** |
1493 |
|
* applyToEitherAsync result completes exceptionally if either source cancelled |
1494 |
|
*/ |
1498 |
|
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc); |
1499 |
|
assertTrue(f.cancel(true)); |
1500 |
|
checkCompletedWithWrappedCancellationException(g); |
1501 |
< |
|
1501 |
> |
|
1502 |
|
f = new CompletableFuture<Integer>(); |
1503 |
|
f2 = new CompletableFuture<Integer>(); |
1504 |
|
assertTrue(f2.cancel(true)); |
1556 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1557 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1558 |
|
FailingConsumer r = new FailingConsumer(); |
1559 |
< |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
1559 |
> |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
1560 |
|
f.complete(one); |
1561 |
|
checkCompletedWithWrappedCFException(g); |
1562 |
|
} |
1563 |
< |
|
1563 |
> |
|
1564 |
|
/** |
1565 |
|
* acceptEitherAsync result completes exceptionally if either |
1566 |
|
* source cancelled |
1572 |
|
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
1573 |
|
assertTrue(f.cancel(true)); |
1574 |
|
checkCompletedWithWrappedCancellationException(g); |
1575 |
< |
|
1575 |
> |
|
1576 |
|
r = new IncAction(); |
1577 |
|
f = new CompletableFuture<Integer>(); |
1578 |
|
f2 = new CompletableFuture<Integer>(); |
1631 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1632 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1633 |
|
FailingNoop r = new FailingNoop(); |
1634 |
< |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
1634 |
> |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
1635 |
|
f.complete(one); |
1636 |
|
checkCompletedWithWrappedCFException(g); |
1637 |
|
} |
1638 |
< |
|
1638 |
> |
|
1639 |
|
/** |
1640 |
|
* runAfterEitherAsync result completes exceptionally if either |
1641 |
|
* source cancelled |
1647 |
|
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
1648 |
|
assertTrue(f.cancel(true)); |
1649 |
|
checkCompletedWithWrappedCancellationException(g); |
1650 |
< |
|
1650 |
> |
|
1651 |
|
r = new Noop(); |
1652 |
|
f = new CompletableFuture<Integer>(); |
1653 |
|
f2 = new CompletableFuture<Integer>(); |
1657 |
|
} |
1658 |
|
|
1659 |
|
/** |
1660 |
< |
* thenCompse result completes normally after normal completion of source |
1660 |
> |
* thenComposeAsync result completes normally after normal |
1661 |
> |
* completion of source |
1662 |
|
*/ |
1663 |
|
public void testThenComposeAsync() { |
1664 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1669 |
|
} |
1670 |
|
|
1671 |
|
/** |
1672 |
< |
* thenComposeAsync result completes exceptionally after exceptional |
1673 |
< |
* completion of source |
1672 |
> |
* thenComposeAsync result completes exceptionally after |
1673 |
> |
* exceptional completion of source |
1674 |
|
*/ |
1675 |
|
public void testThenComposeAsync2() { |
1676 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1703 |
|
} |
1704 |
|
|
1705 |
|
|
1706 |
< |
// aaync with explicit executors |
1706 |
> |
// async with explicit executors |
1707 |
|
|
1708 |
|
/** |
1709 |
|
* thenRunAsync result completes normally after normal completion of source |
1735 |
|
try { |
1736 |
|
g.join(); |
1737 |
|
shouldThrow(); |
1738 |
< |
} catch(Exception ok) { |
1738 |
> |
} catch (Exception ok) { |
1739 |
|
} |
1740 |
|
checkCompletedWithWrappedCFException(g); |
1741 |
|
} |
1750 |
|
f.complete(null); |
1751 |
|
checkCompletedWithWrappedCFException(g); |
1752 |
|
} |
1753 |
< |
|
1753 |
> |
|
1754 |
|
/** |
1755 |
|
* thenRunAsync result completes exceptionally if source cancelled |
1756 |
|
*/ |
1793 |
|
f.complete(null); |
1794 |
|
checkCompletedWithWrappedCFException(g); |
1795 |
|
} |
1796 |
< |
|
1796 |
> |
|
1797 |
|
/** |
1798 |
|
* thenApplyAsync result completes exceptionally if source cancelled |
1799 |
|
*/ |
1839 |
|
f.complete(null); |
1840 |
|
checkCompletedWithWrappedCFException(g); |
1841 |
|
} |
1842 |
< |
|
1842 |
> |
|
1843 |
|
/** |
1844 |
|
* thenAcceptAsync result completes exceptionally if source cancelled |
1845 |
|
*/ |
1897 |
|
f2.complete(two); |
1898 |
|
checkCompletedWithWrappedCFException(g); |
1899 |
|
} |
1900 |
< |
|
1900 |
> |
|
1901 |
|
/** |
1902 |
|
* thenCombineAsync result completes exceptionally if either source cancelled |
1903 |
|
*/ |
1908 |
|
assertTrue(f.cancel(true)); |
1909 |
|
f2.complete(two); |
1910 |
|
checkCompletedWithWrappedCancellationException(g); |
1911 |
< |
|
1911 |
> |
|
1912 |
|
f = new CompletableFuture<Integer>(); |
1913 |
|
f2 = new CompletableFuture<Integer>(); |
1914 |
|
g = f.thenCombineAsync(f2, add, new ThreadExecutor()); |
1962 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
1963 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
1964 |
|
FailingBiConsumer r = new FailingBiConsumer(); |
1965 |
< |
CompletableFuture<Void> g = f.thenAcceptBothAsync(f2, r, new ThreadExecutor()); |
1965 |
> |
CompletableFuture<Void> g = f.thenAcceptBothAsync(f2, r, new ThreadExecutor()); |
1966 |
|
f.complete(one); |
1967 |
|
checkIncomplete(g); |
1968 |
|
f2.complete(two); |
1969 |
|
checkCompletedWithWrappedCFException(g); |
1970 |
|
} |
1971 |
< |
|
1971 |
> |
|
1972 |
|
/** |
1973 |
|
* thenAcceptBothAsync result completes exceptionally if either source cancelled |
1974 |
|
*/ |
1980 |
|
assertTrue(f.cancel(true)); |
1981 |
|
f2.complete(two); |
1982 |
|
checkCompletedWithWrappedCancellationException(g); |
1983 |
< |
|
1983 |
> |
|
1984 |
|
r = new AddAction(); |
1985 |
|
f = new CompletableFuture<Integer>(); |
1986 |
|
f2 = new CompletableFuture<Integer>(); |
2035 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2036 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
2037 |
|
FailingNoop r = new FailingNoop(); |
2038 |
< |
CompletableFuture<Void> g = f.runAfterBothAsync(f2, r, new ThreadExecutor()); |
2038 |
> |
CompletableFuture<Void> g = f.runAfterBothAsync(f2, r, new ThreadExecutor()); |
2039 |
|
f.complete(one); |
2040 |
|
checkIncomplete(g); |
2041 |
|
f2.complete(two); |
2042 |
|
checkCompletedWithWrappedCFException(g); |
2043 |
|
} |
2044 |
< |
|
2044 |
> |
|
2045 |
|
/** |
2046 |
|
* runAfterBothAsync result completes exceptionally if either source cancelled |
2047 |
|
*/ |
2053 |
|
assertTrue(f.cancel(true)); |
2054 |
|
f2.complete(two); |
2055 |
|
checkCompletedWithWrappedCancellationException(g); |
2056 |
< |
|
2056 |
> |
|
2057 |
|
r = new Noop(); |
2058 |
|
f = new CompletableFuture<Integer>(); |
2059 |
|
f2 = new CompletableFuture<Integer>(); |
2107 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2108 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
2109 |
|
FailingFunction r = new FailingFunction(); |
2110 |
< |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r, new ThreadExecutor()); |
2110 |
> |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r, new ThreadExecutor()); |
2111 |
|
f.complete(one); |
2112 |
|
checkCompletedWithWrappedCFException(g); |
2113 |
|
} |
2114 |
< |
|
2114 |
> |
|
2115 |
|
/** |
2116 |
|
* applyToEitherAsync result completes exceptionally if either source cancelled |
2117 |
|
*/ |
2121 |
|
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2122 |
|
assertTrue(f.cancel(true)); |
2123 |
|
checkCompletedWithWrappedCancellationException(g); |
2124 |
< |
|
2124 |
> |
|
2125 |
|
f = new CompletableFuture<Integer>(); |
2126 |
|
f2 = new CompletableFuture<Integer>(); |
2127 |
|
assertTrue(f2.cancel(true)); |
2179 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2180 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
2181 |
|
FailingConsumer r = new FailingConsumer(); |
2182 |
< |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2182 |
> |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2183 |
|
f.complete(one); |
2184 |
|
checkCompletedWithWrappedCFException(g); |
2185 |
|
} |
2186 |
< |
|
2186 |
> |
|
2187 |
|
/** |
2188 |
|
* acceptEitherAsync result completes exceptionally if either |
2189 |
|
* source cancelled |
2195 |
|
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2196 |
|
assertTrue(f.cancel(true)); |
2197 |
|
checkCompletedWithWrappedCancellationException(g); |
2198 |
< |
|
2198 |
> |
|
2199 |
|
r = new IncAction(); |
2200 |
|
f = new CompletableFuture<Integer>(); |
2201 |
|
f2 = new CompletableFuture<Integer>(); |
2254 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2255 |
|
CompletableFuture<Integer> f2 = new CompletableFuture<Integer>(); |
2256 |
|
FailingNoop r = new FailingNoop(); |
2257 |
< |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2257 |
> |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2258 |
|
f.complete(one); |
2259 |
|
checkCompletedWithWrappedCFException(g); |
2260 |
|
} |
2261 |
< |
|
2261 |
> |
|
2262 |
|
/** |
2263 |
|
* runAfterEitherAsync result completes exceptionally if either |
2264 |
|
* source cancelled |
2270 |
|
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2271 |
|
assertTrue(f.cancel(true)); |
2272 |
|
checkCompletedWithWrappedCancellationException(g); |
2273 |
< |
|
2273 |
> |
|
2274 |
|
r = new Noop(); |
2275 |
|
f = new CompletableFuture<Integer>(); |
2276 |
|
f2 = new CompletableFuture<Integer>(); |
2280 |
|
} |
2281 |
|
|
2282 |
|
/** |
2283 |
< |
* thenCompse result completes normally after normal completion of source |
2283 |
> |
* thenComposeAsync result completes normally after normal |
2284 |
> |
* completion of source |
2285 |
|
*/ |
2286 |
|
public void testThenComposeAsyncE() { |
2287 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2292 |
|
} |
2293 |
|
|
2294 |
|
/** |
2295 |
< |
* thenComposeAsync result completes exceptionally after exceptional |
2296 |
< |
* completion of source |
2295 |
> |
* thenComposeAsync result completes exceptionally after |
2296 |
> |
* exceptional completion of source |
2297 |
|
*/ |
2298 |
|
public void testThenComposeAsync2E() { |
2299 |
|
CompletableFuture<Integer> f = new CompletableFuture<Integer>(); |
2325 |
|
checkCompletedWithWrappedCancellationException(g); |
2326 |
|
} |
2327 |
|
|
2328 |
< |
// other static methods |
2328 |
> |
// other static methods |
2329 |
|
|
2330 |
|
/** |
2331 |
|
* allOf(no component futures) returns a future completed normally |
2342 |
|
public void testAllOf() throws Exception { |
2343 |
|
for (int k = 1; k < 20; ++k) { |
2344 |
|
CompletableFuture[] fs = new CompletableFuture[k]; |
2345 |
< |
for (int i = 0; i < k; ++i) |
2345 |
> |
for (int i = 0; i < k; ++i) |
2346 |
|
fs[i] = new CompletableFuture<Integer>(); |
2347 |
|
CompletableFuture<?> f = CompletableFuture.allOf(fs); |
2348 |
|
for (int i = 0; i < k; ++i) { |
2368 |
|
public void testAnyOf() throws Exception { |
2369 |
|
for (int k = 1; k < 20; ++k) { |
2370 |
|
CompletableFuture[] fs = new CompletableFuture[k]; |
2371 |
< |
for (int i = 0; i < k; ++i) |
2371 |
> |
for (int i = 0; i < k; ++i) |
2372 |
|
fs[i] = new CompletableFuture<Integer>(); |
2373 |
|
CompletableFuture<?> f = CompletableFuture.anyOf(fs); |
2374 |
|
checkIncomplete(f); |