145 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
146 |
|
} |
147 |
|
|
148 |
< |
void checkTaskThrew(RecursiveTask a, Throwable t) { |
148 |
> |
void checkCompletedAbnormally(RecursiveTask a, Throwable t) { |
149 |
|
assertTrue(a.isDone()); |
150 |
|
assertFalse(a.isCancelled()); |
151 |
|
assertFalse(a.isCompletedNormally()); |
344 |
|
f.invoke(); |
345 |
|
shouldThrow(); |
346 |
|
} catch (FJException success) { |
347 |
< |
checkTaskThrew(f, success); |
347 |
> |
checkCompletedAbnormally(f, success); |
348 |
|
} |
349 |
|
return NoResult; |
350 |
|
}}; |
360 |
|
FailingFibTask f = new FailingFibTask(8); |
361 |
|
f.quietlyInvoke(); |
362 |
|
assertTrue(f.getException() instanceof FJException); |
363 |
< |
checkTaskThrew(f, f.getException()); |
363 |
> |
checkCompletedAbnormally(f, f.getException()); |
364 |
|
return NoResult; |
365 |
|
}}; |
366 |
|
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
378 |
|
Integer r = f.join(); |
379 |
|
shouldThrow(); |
380 |
|
} catch (FJException success) { |
381 |
< |
checkTaskThrew(f, success); |
381 |
> |
checkCompletedAbnormally(f, success); |
382 |
|
} |
383 |
|
return NoResult; |
384 |
|
}}; |
397 |
|
Integer r = f.get(); |
398 |
|
shouldThrow(); |
399 |
|
} catch (ExecutionException success) { |
400 |
< |
checkTaskThrew(f, success.getCause()); |
400 |
> |
Throwable cause = success.getCause(); |
401 |
> |
assertTrue(cause instanceof FJException); |
402 |
> |
checkCompletedAbnormally(f, cause); |
403 |
|
} |
404 |
|
return NoResult; |
405 |
|
}}; |
418 |
|
Integer r = f.get(5L, SECONDS); |
419 |
|
shouldThrow(); |
420 |
|
} catch (ExecutionException success) { |
421 |
< |
checkTaskThrew(f, success.getCause()); |
421 |
> |
Throwable cause = success.getCause(); |
422 |
> |
assertTrue(cause instanceof FJException); |
423 |
> |
checkCompletedAbnormally(f, cause); |
424 |
|
} |
425 |
|
return NoResult; |
426 |
|
}}; |
437 |
|
assertSame(f, f.fork()); |
438 |
|
f.quietlyJoin(); |
439 |
|
assertTrue(f.getException() instanceof FJException); |
440 |
< |
checkTaskThrew(f, f.getException()); |
440 |
> |
checkCompletedAbnormally(f, f.getException()); |
441 |
|
return NoResult; |
442 |
|
}}; |
443 |
|
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
581 |
|
public void testInForkJoinPool2() { |
582 |
|
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
583 |
|
public Integer realCompute() { |
584 |
< |
assertTrue(!inForkJoinPool()); |
584 |
> |
assertFalse(inForkJoinPool()); |
585 |
|
return NoResult; |
586 |
|
}}; |
587 |
|
assertSame(NoResult, a.invoke()); |
637 |
|
f.invoke(); |
638 |
|
shouldThrow(); |
639 |
|
} catch (FJException success) { |
640 |
< |
checkTaskThrew(f, success); |
640 |
> |
checkCompletedAbnormally(f, success); |
641 |
|
} |
642 |
|
f.reinitialize(); |
643 |
|
checkNotDone(f); |
659 |
|
Integer r = f.invoke(); |
660 |
|
shouldThrow(); |
661 |
|
} catch (FJException success) { |
662 |
< |
checkTaskThrew(f, success); |
662 |
> |
checkCompletedAbnormally(f, success); |
663 |
|
} |
664 |
|
return NoResult; |
665 |
|
}}; |
789 |
|
invokeAll(f, g); |
790 |
|
shouldThrow(); |
791 |
|
} catch (FJException success) { |
792 |
< |
checkTaskThrew(g, success); |
792 |
> |
checkCompletedAbnormally(g, success); |
793 |
|
} |
794 |
|
return NoResult; |
795 |
|
}}; |
807 |
|
invokeAll(g); |
808 |
|
shouldThrow(); |
809 |
|
} catch (FJException success) { |
810 |
< |
checkTaskThrew(g, success); |
810 |
> |
checkCompletedAbnormally(g, success); |
811 |
|
} |
812 |
|
return NoResult; |
813 |
|
}}; |
827 |
|
invokeAll(f, g, h); |
828 |
|
shouldThrow(); |
829 |
|
} catch (FJException success) { |
830 |
< |
checkTaskThrew(g, success); |
830 |
> |
checkCompletedAbnormally(g, success); |
831 |
|
} |
832 |
|
return NoResult; |
833 |
|
}}; |
851 |
|
invokeAll(set); |
852 |
|
shouldThrow(); |
853 |
|
} catch (FJException success) { |
854 |
< |
checkTaskThrew(f, success); |
854 |
> |
checkCompletedAbnormally(f, success); |
855 |
|
} |
856 |
|
return NoResult; |
857 |
|
}}; |
893 |
|
assertSame(f, f.fork()); |
894 |
|
assertTrue(getSurplusQueuedTaskCount() > 0); |
895 |
|
helpQuiesce(); |
896 |
+ |
assertEquals(0, getSurplusQueuedTaskCount()); |
897 |
|
checkCompletedNormally(f, 21); |
898 |
|
checkCompletedNormally(g, 34); |
899 |
|
checkCompletedNormally(h, 13); |