--- jsr166/src/test/tck/ForkJoinTaskTest.java 2015/10/11 19:53:59 1.48 +++ jsr166/src/test/tck/ForkJoinTaskTest.java 2016/08/24 22:22:39 1.51 @@ -8,9 +8,7 @@ import static java.util.concurrent.TimeU import static java.util.concurrent.TimeUnit.SECONDS; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; @@ -776,6 +774,27 @@ public class ForkJoinTaskTest extends JS } /** + * completeExceptionally(null) surprisingly has the same effect as + * completeExceptionally(new RuntimeException()) + */ + public void testCompleteExceptionally_null() { + RecursiveAction a = new CheckedRecursiveAction() { + protected void realCompute() { + AsyncFib f = new AsyncFib(8); + f.completeExceptionally(null); + try { + f.invoke(); + shouldThrow(); + } catch (RuntimeException success) { + assertSame(success.getClass(), RuntimeException.class); + assertNull(success.getCause()); + checkCompletedAbnormally(f, success); + } + }}; + testInvokeOnPool(mainPool(), a); + } + + /** * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2() { @@ -876,7 +895,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); ForkJoinTask[] tasks = { f, g }; - Collections.shuffle(Arrays.asList(tasks)); + shuffle(tasks); try { invokeAll(tasks); shouldThrow(); @@ -914,7 +933,7 @@ public class ForkJoinTaskTest extends JS FailingAsyncFib g = new FailingAsyncFib(9); AsyncFib h = new AsyncFib(7); ForkJoinTask[] tasks = { f, g, h }; - Collections.shuffle(Arrays.asList(tasks)); + shuffle(tasks); try { invokeAll(tasks); shouldThrow(); @@ -935,10 +954,9 @@ public class ForkJoinTaskTest extends JS AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); ForkJoinTask[] tasks = { f, g, h }; - List taskList = Arrays.asList(tasks); - Collections.shuffle(taskList); + shuffle(tasks); try { - invokeAll(taskList); + invokeAll(Arrays.asList(tasks)); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success); @@ -1546,7 +1564,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); ForkJoinTask[] tasks = { f, g }; - Collections.shuffle(Arrays.asList(tasks)); + shuffle(tasks); try { invokeAll(tasks); shouldThrow(); @@ -1584,7 +1602,7 @@ public class ForkJoinTaskTest extends JS FailingAsyncFib g = new FailingAsyncFib(9); AsyncFib h = new AsyncFib(7); ForkJoinTask[] tasks = { f, g, h }; - Collections.shuffle(Arrays.asList(tasks)); + shuffle(tasks); try { invokeAll(tasks); shouldThrow(); @@ -1605,10 +1623,9 @@ public class ForkJoinTaskTest extends JS AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); ForkJoinTask[] tasks = { f, g, h }; - List taskList = Arrays.asList(tasks); - Collections.shuffle(taskList); + shuffle(tasks); try { - invokeAll(taskList); + invokeAll(Arrays.asList(tasks)); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success);