8 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
9 |
|
|
10 |
|
import java.util.Arrays; |
11 |
– |
import java.util.Collections; |
11 |
|
import java.util.HashSet; |
13 |
– |
import java.util.List; |
12 |
|
import java.util.concurrent.CancellationException; |
13 |
|
import java.util.concurrent.ExecutionException; |
14 |
|
import java.util.concurrent.ForkJoinPool; |
774 |
|
} |
775 |
|
|
776 |
|
/** |
777 |
+ |
* completeExceptionally(null) surprisingly has the same effect as |
778 |
+ |
* completeExceptionally(new RuntimeException()) |
779 |
+ |
*/ |
780 |
+ |
public void testCompleteExceptionally_null() { |
781 |
+ |
RecursiveAction a = new CheckedRecursiveAction() { |
782 |
+ |
protected void realCompute() { |
783 |
+ |
AsyncFib f = new AsyncFib(8); |
784 |
+ |
f.completeExceptionally(null); |
785 |
+ |
try { |
786 |
+ |
f.invoke(); |
787 |
+ |
shouldThrow(); |
788 |
+ |
} catch (RuntimeException success) { |
789 |
+ |
assertSame(success.getClass(), RuntimeException.class); |
790 |
+ |
assertNull(success.getCause()); |
791 |
+ |
checkCompletedAbnormally(f, success); |
792 |
+ |
} |
793 |
+ |
}}; |
794 |
+ |
testInvokeOnPool(mainPool(), a); |
795 |
+ |
} |
796 |
+ |
|
797 |
+ |
/** |
798 |
|
* invokeAll(t1, t2) invokes all task arguments |
799 |
|
*/ |
800 |
|
public void testInvokeAll2() { |
895 |
|
AsyncFib f = new AsyncFib(8); |
896 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
897 |
|
ForkJoinTask[] tasks = { f, g }; |
898 |
< |
Collections.shuffle(Arrays.asList(tasks)); |
898 |
> |
shuffle(tasks); |
899 |
|
try { |
900 |
|
invokeAll(tasks); |
901 |
|
shouldThrow(); |
933 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
934 |
|
AsyncFib h = new AsyncFib(7); |
935 |
|
ForkJoinTask[] tasks = { f, g, h }; |
936 |
< |
Collections.shuffle(Arrays.asList(tasks)); |
936 |
> |
shuffle(tasks); |
937 |
|
try { |
938 |
|
invokeAll(tasks); |
939 |
|
shouldThrow(); |
954 |
|
AsyncFib g = new AsyncFib(9); |
955 |
|
AsyncFib h = new AsyncFib(7); |
956 |
|
ForkJoinTask[] tasks = { f, g, h }; |
957 |
< |
List taskList = Arrays.asList(tasks); |
939 |
< |
Collections.shuffle(taskList); |
957 |
> |
shuffle(tasks); |
958 |
|
try { |
959 |
< |
invokeAll(taskList); |
959 |
> |
invokeAll(Arrays.asList(tasks)); |
960 |
|
shouldThrow(); |
961 |
|
} catch (FJException success) { |
962 |
|
checkCompletedAbnormally(f, success); |
1564 |
|
AsyncFib f = new AsyncFib(8); |
1565 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
1566 |
|
ForkJoinTask[] tasks = { f, g }; |
1567 |
< |
Collections.shuffle(Arrays.asList(tasks)); |
1567 |
> |
shuffle(tasks); |
1568 |
|
try { |
1569 |
|
invokeAll(tasks); |
1570 |
|
shouldThrow(); |
1602 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
1603 |
|
AsyncFib h = new AsyncFib(7); |
1604 |
|
ForkJoinTask[] tasks = { f, g, h }; |
1605 |
< |
Collections.shuffle(Arrays.asList(tasks)); |
1605 |
> |
shuffle(tasks); |
1606 |
|
try { |
1607 |
|
invokeAll(tasks); |
1608 |
|
shouldThrow(); |
1623 |
|
AsyncFib g = new AsyncFib(9); |
1624 |
|
AsyncFib h = new AsyncFib(7); |
1625 |
|
ForkJoinTask[] tasks = { f, g, h }; |
1626 |
< |
List taskList = Arrays.asList(tasks); |
1609 |
< |
Collections.shuffle(taskList); |
1626 |
> |
shuffle(tasks); |
1627 |
|
try { |
1628 |
< |
invokeAll(taskList); |
1628 |
> |
invokeAll(Arrays.asList(tasks)); |
1629 |
|
shouldThrow(); |
1630 |
|
} catch (FJException success) { |
1631 |
|
checkCompletedAbnormally(f, success); |