349 |
|
} |
350 |
|
} |
351 |
|
static final class IncFunction implements Function<Integer,Integer> { |
352 |
+ |
final ExecutionMode m; |
353 |
|
int invocationCount = 0; |
354 |
|
Integer value; |
355 |
+ |
IncFunction(ExecutionMode m) { this.m = m; } |
356 |
|
public Integer apply(Integer x) { |
357 |
+ |
m.checkExecutionMode(); |
358 |
|
invocationCount++; |
359 |
|
return value = inc(x); |
360 |
|
} |
361 |
|
} |
362 |
|
static final class SubtractAction implements BiConsumer<Integer, Integer> { |
363 |
+ |
final ExecutionMode m; |
364 |
|
int invocationCount = 0; |
365 |
|
Integer value; |
366 |
|
// Check this action was invoked exactly once when result is computed. |
367 |
+ |
SubtractAction(ExecutionMode m) { this.m = m; } |
368 |
|
public void accept(Integer x, Integer y) { |
369 |
+ |
m.checkExecutionMode(); |
370 |
|
invocationCount++; |
371 |
|
value = subtract(x, y); |
372 |
|
} |
373 |
|
} |
374 |
|
static final class SubtractFunction implements BiFunction<Integer, Integer, Integer> { |
375 |
+ |
final ExecutionMode m; |
376 |
|
int invocationCount = 0; |
377 |
|
Integer value; |
378 |
|
// Check this action was invoked exactly once when result is computed. |
379 |
+ |
SubtractFunction(ExecutionMode m) { this.m = m; } |
380 |
|
public Integer apply(Integer x, Integer y) { |
381 |
+ |
m.checkExecutionMode(); |
382 |
|
invocationCount++; |
383 |
|
return value = subtract(x, y); |
384 |
|
} |
394 |
|
} |
395 |
|
|
396 |
|
static final class FailingSupplier implements Supplier<Integer> { |
397 |
+ |
final ExecutionMode m; |
398 |
|
int invocationCount = 0; |
399 |
+ |
FailingSupplier(ExecutionMode m) { this.m = m; } |
400 |
|
public Integer get() { |
401 |
+ |
m.checkExecutionMode(); |
402 |
|
invocationCount++; |
403 |
|
throw new CFException(); |
404 |
|
} |
405 |
|
} |
406 |
|
static final class FailingConsumer implements Consumer<Integer> { |
407 |
+ |
final ExecutionMode m; |
408 |
|
int invocationCount = 0; |
409 |
+ |
FailingConsumer(ExecutionMode m) { this.m = m; } |
410 |
|
public void accept(Integer x) { |
411 |
+ |
m.checkExecutionMode(); |
412 |
|
invocationCount++; |
413 |
|
throw new CFException(); |
414 |
|
} |
415 |
|
} |
416 |
|
static final class FailingBiConsumer implements BiConsumer<Integer, Integer> { |
417 |
+ |
final ExecutionMode m; |
418 |
|
int invocationCount = 0; |
419 |
+ |
FailingBiConsumer(ExecutionMode m) { this.m = m; } |
420 |
|
public void accept(Integer x, Integer y) { |
421 |
+ |
m.checkExecutionMode(); |
422 |
|
invocationCount++; |
423 |
|
throw new CFException(); |
424 |
|
} |
425 |
|
} |
426 |
|
static final class FailingFunction implements Function<Integer, Integer> { |
427 |
+ |
final ExecutionMode m; |
428 |
|
int invocationCount = 0; |
429 |
+ |
FailingFunction(ExecutionMode m) { this.m = m; } |
430 |
|
public Integer apply(Integer x) { |
431 |
+ |
m.checkExecutionMode(); |
432 |
|
invocationCount++; |
433 |
|
throw new CFException(); |
434 |
|
} |
435 |
|
} |
436 |
|
static final class FailingBiFunction implements BiFunction<Integer, Integer, Integer> { |
437 |
+ |
final ExecutionMode m; |
438 |
|
int invocationCount = 0; |
439 |
+ |
FailingBiFunction(ExecutionMode m) { this.m = m; } |
440 |
|
public Integer apply(Integer x, Integer y) { |
441 |
+ |
m.checkExecutionMode(); |
442 |
|
invocationCount++; |
443 |
|
throw new CFException(); |
444 |
|
} |
445 |
|
} |
446 |
|
static final class FailingRunnable implements Runnable { |
447 |
+ |
final ExecutionMode m; |
448 |
|
int invocationCount = 0; |
449 |
+ |
FailingRunnable(ExecutionMode m) { this.m = m; } |
450 |
|
public void run() { |
451 |
+ |
m.checkExecutionMode(); |
452 |
|
invocationCount++; |
453 |
|
throw new CFException(); |
454 |
|
} |
456 |
|
|
457 |
|
static final class CompletableFutureInc |
458 |
|
implements Function<Integer, CompletableFuture<Integer>> { |
459 |
+ |
final ExecutionMode m; |
460 |
|
int invocationCount = 0; |
461 |
+ |
CompletableFutureInc(ExecutionMode m) { this.m = m; } |
462 |
|
public CompletableFuture<Integer> apply(Integer x) { |
463 |
+ |
m.checkExecutionMode(); |
464 |
|
invocationCount++; |
465 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
466 |
|
f.complete(inc(x)); |
470 |
|
|
471 |
|
static final class FailingCompletableFutureFunction |
472 |
|
implements Function<Integer, CompletableFuture<Integer>> { |
473 |
+ |
final ExecutionMode m; |
474 |
|
int invocationCount = 0; |
475 |
+ |
FailingCompletableFutureFunction(ExecutionMode m) { this.m = m; } |
476 |
|
public CompletableFuture<Integer> apply(Integer x) { |
477 |
+ |
m.checkExecutionMode(); |
478 |
|
invocationCount++; |
479 |
|
throw new CFException(); |
480 |
|
} |
482 |
|
|
483 |
|
// Used for explicit executor tests |
484 |
|
static final class ThreadExecutor implements Executor { |
485 |
< |
AtomicInteger count = new AtomicInteger(0); |
485 |
> |
final AtomicInteger count = new AtomicInteger(0); |
486 |
> |
static final ThreadGroup tg = new ThreadGroup("ThreadExecutor"); |
487 |
> |
static boolean startedCurrentThread() { |
488 |
> |
return Thread.currentThread().getThreadGroup() == tg; |
489 |
> |
} |
490 |
|
|
491 |
|
public void execute(Runnable r) { |
492 |
|
count.getAndIncrement(); |
493 |
< |
new Thread(r).start(); |
493 |
> |
new Thread(tg, r).start(); |
494 |
|
} |
495 |
|
} |
496 |
|
|
636 |
|
|
637 |
|
EXECUTOR { |
638 |
|
public void checkExecutionMode() { |
639 |
< |
//TODO |
639 |
> |
assertTrue(ThreadExecutor.startedCurrentThread()); |
640 |
|
} |
641 |
|
public <T> CompletableFuture<Void> thenRun |
642 |
|
(CompletableFuture<T> f, Runnable a) { |
973 |
|
* failing runAsync completes exceptionally after running Runnable |
974 |
|
*/ |
975 |
|
public void testRunAsync3() { |
976 |
< |
FailingRunnable r = new FailingRunnable(); |
976 |
> |
FailingRunnable r = new FailingRunnable(ExecutionMode.ASYNC); |
977 |
|
CompletableFuture<Void> f = CompletableFuture.runAsync(r); |
978 |
|
checkCompletedWithWrappedCFException(f); |
979 |
|
assertEquals(1, r.invocationCount); |
1003 |
|
* Failing supplyAsync completes exceptionally |
1004 |
|
*/ |
1005 |
|
public void testSupplyAsync3() { |
1006 |
< |
FailingSupplier r = new FailingSupplier(); |
1006 |
> |
FailingSupplier r = new FailingSupplier(ExecutionMode.ASYNC); |
1007 |
|
CompletableFuture<Integer> f = CompletableFuture.supplyAsync(r); |
1008 |
|
checkCompletedWithWrappedCFException(f); |
1009 |
|
assertEquals(1, r.invocationCount); |
1067 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1068 |
|
final Noop r = new Noop(m); |
1069 |
|
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1070 |
< |
final CompletableFuture<Void> g = f.thenRun(r); |
1070 |
> |
final CompletableFuture<Void> g = m.thenRun(f, r); |
1071 |
|
if (createIncomplete) { |
1072 |
|
checkIncomplete(g); |
1073 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
1087 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1088 |
|
{ |
1089 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1090 |
< |
final FailingRunnable r = new FailingRunnable(); |
1090 |
> |
final FailingRunnable r = new FailingRunnable(m); |
1091 |
|
if (!createIncomplete) f.complete(v1); |
1092 |
< |
final CompletableFuture<Void> g = f.thenRun(r); |
1092 |
> |
final CompletableFuture<Void> g = m.thenRun(f, r); |
1093 |
|
if (createIncomplete) { |
1094 |
|
checkIncomplete(g); |
1095 |
|
f.complete(v1); |
1108 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1109 |
|
{ |
1110 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1111 |
< |
final IncFunction r = new IncFunction(); |
1111 |
> |
final IncFunction r = new IncFunction(m); |
1112 |
|
if (!createIncomplete) f.complete(v1); |
1113 |
|
final CompletableFuture<Integer> g = m.thenApply(f, r); |
1114 |
|
if (createIncomplete) { |
1131 |
|
{ |
1132 |
|
final CFException ex = new CFException(); |
1133 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1134 |
< |
final IncFunction r = new IncFunction(); |
1134 |
> |
final IncFunction r = new IncFunction(m); |
1135 |
|
if (!createIncomplete) f.completeExceptionally(ex); |
1136 |
|
final CompletableFuture<Integer> g = m.thenApply(f, r); |
1137 |
|
if (createIncomplete) { |
1153 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1154 |
|
{ |
1155 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1156 |
< |
final IncFunction r = new IncFunction(); |
1156 |
> |
final IncFunction r = new IncFunction(m); |
1157 |
|
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1158 |
< |
final CompletableFuture<Integer> g = f.thenApply(r); |
1158 |
> |
final CompletableFuture<Integer> g = m.thenApply(f, r); |
1159 |
|
if (createIncomplete) { |
1160 |
|
checkIncomplete(g); |
1161 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
1175 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1176 |
|
{ |
1177 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1178 |
< |
final FailingFunction r = new FailingFunction(); |
1178 |
> |
final FailingFunction r = new FailingFunction(m); |
1179 |
|
if (!createIncomplete) f.complete(v1); |
1180 |
< |
final CompletableFuture<Integer> g = f.thenApply(r); |
1180 |
> |
final CompletableFuture<Integer> g = m.thenApply(f, r); |
1181 |
|
if (createIncomplete) { |
1182 |
|
checkIncomplete(g); |
1183 |
|
f.complete(v1); |
1242 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1243 |
|
{ |
1244 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1245 |
< |
final FailingConsumer r = new FailingConsumer(); |
1245 |
> |
final FailingConsumer r = new FailingConsumer(m); |
1246 |
|
if (!createIncomplete) f.complete(v1); |
1247 |
< |
final CompletableFuture<Void> g = f.thenAccept(r); |
1247 |
> |
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1248 |
|
if (createIncomplete) { |
1249 |
|
checkIncomplete(g); |
1250 |
|
f.complete(v1); |
1265 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1266 |
|
final IncAction r = new IncAction(); |
1267 |
|
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1268 |
< |
final CompletableFuture<Void> g = f.thenAccept(r); |
1268 |
> |
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1269 |
|
if (createIncomplete) { |
1270 |
|
checkIncomplete(g); |
1271 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
1289 |
|
{ |
1290 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1291 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1292 |
< |
final SubtractFunction r = new SubtractFunction(); |
1292 |
> |
final SubtractFunction r = new SubtractFunction(m); |
1293 |
|
|
1294 |
|
if (fFirst) f.complete(v1); else g.complete(v2); |
1295 |
|
if (!createIncomplete) |
1320 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1321 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1322 |
|
final CFException ex = new CFException(); |
1323 |
< |
final SubtractFunction r = new SubtractFunction(); |
1323 |
> |
final SubtractFunction r = new SubtractFunction(m); |
1324 |
|
|
1325 |
|
(fFirst ? f : g).complete(v1); |
1326 |
|
if (!createIncomplete) |
1348 |
|
{ |
1349 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1350 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1351 |
< |
final FailingBiFunction r = new FailingBiFunction(); |
1351 |
> |
final FailingBiFunction r = new FailingBiFunction(m); |
1352 |
|
final CompletableFuture<Integer> h = m.thenCombine(f, g, r); |
1353 |
|
|
1354 |
|
if (fFirst) { |
1376 |
|
{ |
1377 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1378 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1379 |
< |
final SubtractFunction r = new SubtractFunction(); |
1379 |
> |
final SubtractFunction r = new SubtractFunction(m); |
1380 |
|
|
1381 |
|
(fFirst ? f : g).complete(v1); |
1382 |
|
if (!createIncomplete) |
1406 |
|
{ |
1407 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1408 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1409 |
< |
final SubtractAction r = new SubtractAction(); |
1409 |
> |
final SubtractAction r = new SubtractAction(m); |
1410 |
|
|
1411 |
|
if (fFirst) f.complete(v1); else g.complete(v2); |
1412 |
|
if (!createIncomplete) |
1437 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1438 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1439 |
|
final CFException ex = new CFException(); |
1440 |
< |
final SubtractAction r = new SubtractAction(); |
1440 |
> |
final SubtractAction r = new SubtractAction(m); |
1441 |
|
|
1442 |
|
(fFirst ? f : g).complete(v1); |
1443 |
|
if (!createIncomplete) |
1465 |
|
{ |
1466 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1467 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1468 |
< |
final FailingBiConsumer r = new FailingBiConsumer(); |
1468 |
> |
final FailingBiConsumer r = new FailingBiConsumer(m); |
1469 |
|
final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r); |
1470 |
|
|
1471 |
|
if (fFirst) { |
1493 |
|
{ |
1494 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1495 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1496 |
< |
final SubtractAction r = new SubtractAction(); |
1496 |
> |
final SubtractAction r = new SubtractAction(m); |
1497 |
|
|
1498 |
|
(fFirst ? f : g).complete(v1); |
1499 |
|
if (!createIncomplete) |
1582 |
|
{ |
1583 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1584 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1585 |
< |
final FailingRunnable r = new FailingRunnable(); |
1585 |
> |
final FailingRunnable r = new FailingRunnable(m); |
1586 |
|
|
1587 |
|
CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r); |
1588 |
|
if (fFirst) { |
1643 |
|
{ |
1644 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1645 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1646 |
< |
final IncFunction r = new IncFunction(); |
1646 |
> |
final IncFunction r = new IncFunction(m); |
1647 |
|
|
1648 |
|
if (!createIncomplete) |
1649 |
|
if (fFirst) f.complete(v1); else g.complete(v2); |
1669 |
|
{ |
1670 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1671 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1672 |
< |
final IncFunction r = new IncFunction(); |
1672 |
> |
final IncFunction r = new IncFunction(m); |
1673 |
|
|
1674 |
|
if (fFirst) { |
1675 |
|
f.complete(v1); |
1703 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1704 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1705 |
|
final CFException ex = new CFException(); |
1706 |
< |
final IncFunction r = new IncFunction(); |
1706 |
> |
final IncFunction r = new IncFunction(m); |
1707 |
|
|
1708 |
|
if (!createIncomplete) (fFirst ? f : g).completeExceptionally(ex); |
1709 |
|
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1730 |
|
{ |
1731 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1732 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1733 |
< |
final IncFunction r1 = new IncFunction(); |
1734 |
< |
final IncFunction r2 = new IncFunction(); |
1733 |
> |
final IncFunction r1 = new IncFunction(m); |
1734 |
> |
final IncFunction r2 = new IncFunction(m); |
1735 |
|
final CFException ex = new CFException(); |
1736 |
|
final CompletableFuture<Integer> j = (reverseArgs ? g : f); |
1737 |
|
final CompletableFuture<Integer> k = (reverseArgs ? f : g); |
1776 |
|
{ |
1777 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1778 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1779 |
< |
final FailingFunction r = new FailingFunction(); |
1779 |
> |
final FailingFunction r = new FailingFunction(m); |
1780 |
|
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1781 |
|
|
1782 |
|
f.complete(v1); |
1793 |
|
{ |
1794 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1795 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1796 |
< |
final FailingFunction r = new FailingFunction(); |
1796 |
> |
final FailingFunction r = new FailingFunction(m); |
1797 |
|
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1798 |
|
|
1799 |
|
g.complete(v2); |
1815 |
|
{ |
1816 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1817 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1818 |
< |
final IncFunction r = new IncFunction(); |
1818 |
> |
final IncFunction r = new IncFunction(m); |
1819 |
|
|
1820 |
|
if (!createIncomplete) assertTrue((fFirst ? f : g).cancel(mayInterruptIfRunning)); |
1821 |
|
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1843 |
|
{ |
1844 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1845 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1846 |
< |
final IncFunction r1 = new IncFunction(); |
1847 |
< |
final IncFunction r2 = new IncFunction(); |
1846 |
> |
final IncFunction r1 = new IncFunction(m); |
1847 |
> |
final IncFunction r2 = new IncFunction(m); |
1848 |
|
final CFException ex = new CFException(); |
1849 |
|
final CompletableFuture<Integer> j = (reverseArgs ? g : f); |
1850 |
|
final CompletableFuture<Integer> k = (reverseArgs ? f : g); |
2056 |
|
{ |
2057 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2058 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2059 |
< |
final FailingConsumer r = new FailingConsumer(); |
2059 |
> |
final FailingConsumer r = new FailingConsumer(m); |
2060 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2061 |
|
|
2062 |
|
f.complete(v1); |
2073 |
|
{ |
2074 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2075 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2076 |
< |
final FailingConsumer r = new FailingConsumer(); |
2076 |
> |
final FailingConsumer r = new FailingConsumer(m); |
2077 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2078 |
|
|
2079 |
|
g.complete(v2); |
2355 |
|
{ |
2356 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2357 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2358 |
< |
final FailingRunnable r = new FailingRunnable(); |
2358 |
> |
final FailingRunnable r = new FailingRunnable(m); |
2359 |
|
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2360 |
|
|
2361 |
|
f.complete(v1); |
2372 |
|
{ |
2373 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2374 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2375 |
< |
final FailingRunnable r = new FailingRunnable(); |
2375 |
> |
final FailingRunnable r = new FailingRunnable(m); |
2376 |
|
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2377 |
|
|
2378 |
|
g.complete(v2); |
2488 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2489 |
|
{ |
2490 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2491 |
< |
final CompletableFutureInc r = new CompletableFutureInc(); |
2491 |
> |
final CompletableFutureInc r = new CompletableFutureInc(m); |
2492 |
|
if (!createIncomplete) f.complete(v1); |
2493 |
< |
final CompletableFuture<Integer> g = f.thenCompose(r); |
2493 |
> |
final CompletableFuture<Integer> g = m.thenCompose(f, r); |
2494 |
|
if (createIncomplete) f.complete(v1); |
2495 |
|
|
2496 |
|
checkCompletedNormally(g, inc(v1)); |
2507 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
2508 |
|
{ |
2509 |
|
final CFException ex = new CFException(); |
2510 |
< |
final CompletableFutureInc r = new CompletableFutureInc(); |
2510 |
> |
final CompletableFutureInc r = new CompletableFutureInc(m); |
2511 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2512 |
|
if (!createIncomplete) f.completeExceptionally(ex); |
2513 |
< |
final CompletableFuture<Integer> g = f.thenCompose(r); |
2513 |
> |
final CompletableFuture<Integer> g = m.thenCompose(f, r); |
2514 |
|
if (createIncomplete) f.completeExceptionally(ex); |
2515 |
|
|
2516 |
|
checkCompletedWithWrappedCFException(g, ex); |
2528 |
|
{ |
2529 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2530 |
|
final FailingCompletableFutureFunction r |
2531 |
< |
= new FailingCompletableFutureFunction(); |
2531 |
> |
= new FailingCompletableFutureFunction(m); |
2532 |
|
if (!createIncomplete) f.complete(v1); |
2533 |
< |
final CompletableFuture<Integer> g = f.thenCompose(r); |
2533 |
> |
final CompletableFuture<Integer> g = m.thenCompose(f, r); |
2534 |
|
if (createIncomplete) f.complete(v1); |
2535 |
|
|
2536 |
|
checkCompletedWithWrappedCFException(g); |
2546 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2547 |
|
{ |
2548 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2549 |
< |
final CompletableFutureInc r = new CompletableFutureInc(); |
2549 |
> |
final CompletableFutureInc r = new CompletableFutureInc(m); |
2550 |
|
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
2551 |
< |
final CompletableFuture<Integer> g = f.thenCompose(r); |
2551 |
> |
final CompletableFuture<Integer> g = m.thenCompose(f, r); |
2552 |
|
if (createIncomplete) { |
2553 |
|
checkIncomplete(g); |
2554 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
2720 |
|
|
2721 |
|
() -> f.thenCompose(null), |
2722 |
|
() -> f.thenComposeAsync(null), |
2723 |
< |
() -> f.thenComposeAsync(new CompletableFutureInc(), null), |
2723 |
> |
() -> f.thenComposeAsync(new CompletableFutureInc(ExecutionMode.EXECUTOR), null), |
2724 |
|
() -> f.thenComposeAsync(null, exec), |
2725 |
|
|
2726 |
|
() -> f.exceptionally(null), |