--- jsr166/src/test/tck/CountedCompleterTest.java 2015/02/27 21:43:18 1.17 +++ jsr166/src/test/tck/CountedCompleterTest.java 2021/01/26 13:33:05 1.38 @@ -5,7 +5,6 @@ */ import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; import java.util.HashSet; import java.util.concurrent.CancellationException; @@ -23,7 +22,7 @@ import junit.framework.TestSuite; public class CountedCompleterTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { @@ -48,8 +47,8 @@ public class CountedCompleterTest extend null, true); } - private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) { - try { + private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) { + try (PoolCleaner cleaner = cleaner(pool)) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -65,12 +64,10 @@ public class CountedCompleterTest extend assertFalse(a.isCancelled()); assertNull(a.getException()); assertNull(a.getRawResult()); - } finally { - joinPool(pool); } } - void checkNotDone(CountedCompleter a) { + void checkNotDone(CountedCompleter a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -79,7 +76,7 @@ public class CountedCompleterTest extend assertNull(a.getRawResult()); try { - a.get(0L, SECONDS); + a.get(randomExpiredTimeout(), randomTimeUnit()); shouldThrow(); } catch (TimeoutException success) { } catch (Throwable fail) { threadUnexpectedException(fail); } @@ -95,31 +92,33 @@ public class CountedCompleterTest extend { Thread.currentThread().interrupt(); - long t0 = System.nanoTime(); + long startTime = System.nanoTime(); assertNull(a.join()); - assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); Thread.interrupted(); } { Thread.currentThread().interrupt(); - long t0 = System.nanoTime(); + long startTime = System.nanoTime(); a.quietlyJoin(); // should be no-op - assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); Thread.interrupted(); } assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); + + Object v1 = null, v2 = null; try { - assertNull(a.get()); - } catch (Throwable fail) { threadUnexpectedException(fail); } - try { - assertNull(a.get(5L, SECONDS)); + v1 = a.get(); + v2 = a.get(randomTimeout(), randomTimeUnit()); } catch (Throwable fail) { threadUnexpectedException(fail); } + assertNull(v1); + assertNull(v2); } - void checkCancelled(CountedCompleter a) { + void checkCancelled(CountedCompleter a) { assertTrue(a.isDone()); assertTrue(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -138,9 +137,9 @@ public class CountedCompleterTest extend Thread.interrupted(); { - long t0 = System.nanoTime(); + long startTime = System.nanoTime(); a.quietlyJoin(); // should be no-op - assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } try { @@ -150,13 +149,13 @@ public class CountedCompleterTest extend } catch (Throwable fail) { threadUnexpectedException(fail); } try { - a.get(5L, SECONDS); + a.get(randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (CancellationException success) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedAbnormally(CountedCompleter a, Throwable t) { + void checkCompletedAbnormally(CountedCompleter a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -176,9 +175,9 @@ public class CountedCompleterTest extend Thread.interrupted(); { - long t0 = System.nanoTime(); + long startTime = System.nanoTime(); a.quietlyJoin(); // should be no-op - assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } try { @@ -189,7 +188,7 @@ public class CountedCompleterTest extend } catch (Throwable fail) { threadUnexpectedException(fail); } try { - a.get(5L, SECONDS); + a.get(randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (ExecutionException success) { assertSame(t.getClass(), success.getCause().getClass()); @@ -212,26 +211,26 @@ public class CountedCompleterTest extend final AtomicInteger onCompletionN = new AtomicInteger(0); final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0); final AtomicInteger setRawResultN = new AtomicInteger(0); - final AtomicReference rawResult = new AtomicReference(null); + final AtomicReference rawResult = new AtomicReference<>(null); int computeN() { return computeN.get(); } int onCompletionN() { return onCompletionN.get(); } int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); } int setRawResultN() { return setRawResultN.get(); } CheckedCC() { super(); } - CheckedCC(CountedCompleter p) { super(p); } - CheckedCC(CountedCompleter p, int n) { super(p, n); } + CheckedCC(CountedCompleter p) { super(p); } + CheckedCC(CountedCompleter p, int n) { super(p, n); } abstract void realCompute(); public final void compute() { computeN.incrementAndGet(); realCompute(); } - public void onCompletion(CountedCompleter caller) { + public void onCompletion(CountedCompleter caller) { onCompletionN.incrementAndGet(); super.onCompletion(caller); } public boolean onExceptionalCompletion(Throwable ex, - CountedCompleter caller) { + CountedCompleter caller) { onExceptionalCompletionN.incrementAndGet(); assertNotNull(ex); assertTrue(isCompletedAbnormally()); @@ -279,7 +278,10 @@ public class CountedCompleterTest extend final class NoopCC extends CheckedCC { NoopCC() { super(); } - NoopCC(CountedCompleter p) { super(p); } + NoopCC(CountedCompleter p) { super(p); } + NoopCC(CountedCompleter p, int initialPendingCount) { + super(p, initialPendingCount); + } protected void realCompute() {} } @@ -298,6 +300,7 @@ public class CountedCompleterTest extend void testComplete(NoopCC cc, Object x, int pendingCount) { cc.setPendingCount(pendingCount); cc.checkCompletes(x); + assertEquals(pendingCount, cc.getPendingCount()); } /** @@ -311,14 +314,20 @@ public class CountedCompleterTest extend } /** - * completeExceptionally(null) throws NullPointerException + * completeExceptionally(null) surprisingly has the same effect as + * completeExceptionally(new RuntimeException()) */ public void testCompleteExceptionally_null() { + NoopCC a = new NoopCC(); + a.completeExceptionally(null); try { - new NoopCC() - .checkCompletesExceptionally(null); + a.invoke(); shouldThrow(); - } catch (NullPointerException success) {} + } catch (RuntimeException success) { + assertSame(success.getClass(), RuntimeException.class); + assertNull(success.getCause()); + a.checkCompletedExceptionally(success); + } } /** @@ -327,10 +336,15 @@ public class CountedCompleterTest extend public void testSetPendingCount() { NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); - a.setPendingCount(1); - assertEquals(1, a.getPendingCount()); - a.setPendingCount(27); - assertEquals(27, a.getPendingCount()); + int[] vals = { + -1, 0, 1, + Integer.MIN_VALUE, + Integer.MAX_VALUE, + }; + for (int val : vals) { + a.setPendingCount(val); + assertEquals(val, a.getPendingCount()); + } } /** @@ -343,21 +357,26 @@ public class CountedCompleterTest extend assertEquals(1, a.getPendingCount()); a.addToPendingCount(27); assertEquals(28, a.getPendingCount()); + a.addToPendingCount(-28); + assertEquals(0, a.getPendingCount()); } /** * decrementPendingCountUnlessZero decrements reported pending * count unless zero */ - public void testDecrementPendingCount() { - NoopCC a = new NoopCC(); - assertEquals(0, a.getPendingCount()); - a.addToPendingCount(1); + public void testDecrementPendingCountUnlessZero() { + NoopCC a = new NoopCC(null, 2); + assertEquals(2, a.getPendingCount()); + assertEquals(2, a.decrementPendingCountUnlessZero()); assertEquals(1, a.getPendingCount()); - a.decrementPendingCountUnlessZero(); + assertEquals(1, a.decrementPendingCountUnlessZero()); assertEquals(0, a.getPendingCount()); - a.decrementPendingCountUnlessZero(); + assertEquals(0, a.decrementPendingCountUnlessZero()); assertEquals(0, a.getPendingCount()); + a.setPendingCount(-1); + assertEquals(-1, a.decrementPendingCountUnlessZero()); + assertEquals(-2, a.getPendingCount()); } /** @@ -381,9 +400,9 @@ public class CountedCompleterTest extend public void testGetCompleter() { NoopCC a = new NoopCC(); assertNull(a.getCompleter()); - CountedCompleter b = new NoopCC(a); + NoopCC b = new NoopCC(a); assertSame(a, b.getCompleter()); - CountedCompleter c = new NoopCC(b); + NoopCC c = new NoopCC(b); assertSame(b, c.getCompleter()); } @@ -481,7 +500,7 @@ public class CountedCompleterTest extend } /** - * quietlyCompleteRoot completes root task + * quietlyCompleteRoot completes root task and only root task */ public void testQuietlyCompleteRoot() { NoopCC a = new NoopCC(); @@ -506,7 +525,7 @@ public class CountedCompleterTest extend int number; int rnumber; - public CCF(CountedCompleter parent, int n) { + public CCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } @@ -524,10 +543,10 @@ public class CountedCompleterTest extend final class LCCF extends CCF { public LCCF(int n) { this(null, n); } - public LCCF(CountedCompleter parent, int n) { + public LCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; @@ -538,10 +557,10 @@ public class CountedCompleterTest extend } } final class RCCF extends CCF { - public RCCF(CountedCompleter parent, int n) { + public RCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; @@ -557,7 +576,7 @@ public class CountedCompleterTest extend int number; int rnumber; - public FailingCCF(CountedCompleter parent, int n) { + public FailingCCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } @@ -575,10 +594,10 @@ public class CountedCompleterTest extend final class LFCCF extends FailingCCF { public LFCCF(int n) { this(null, n); } - public LFCCF(CountedCompleter parent, int n) { + public LFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); FailingCCF p = (FailingCCF)getCompleter(); int n = number + rnumber; @@ -589,10 +608,10 @@ public class CountedCompleterTest extend } } final class RFCCF extends FailingCCF { - public RFCCF(CountedCompleter parent, int n) { + public RFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); completeExceptionally(new FJException()); } @@ -604,7 +623,7 @@ public class CountedCompleterTest extend * completed tasks; getRawResult returns null. */ public void testInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertNull(f.invoke()); @@ -620,7 +639,7 @@ public class CountedCompleterTest extend * completed tasks */ public void testQuietlyInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); f.quietlyInvoke(); @@ -634,7 +653,7 @@ public class CountedCompleterTest extend * join of a forked task returns when task completes */ public void testForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -649,7 +668,7 @@ public class CountedCompleterTest extend * get of a forked task returns when task completes */ public void testForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -664,7 +683,7 @@ public class CountedCompleterTest extend * timed get of a forked task returns when task completes */ public void testForkTimedGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -679,12 +698,12 @@ public class CountedCompleterTest extend * timed get with null time unit throws NPE */ public void testForkTimedGetNPE() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); try { - f.get(5L, null); + f.get(randomTimeout(), null); shouldThrow(); } catch (NullPointerException success) {} }}; @@ -695,7 +714,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -711,11 +730,13 @@ public class CountedCompleterTest extend * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesce() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); helpQuiesce(); + while (!f.isDone()) // wait out race + ; assertEquals(21, f.number); assertEquals(0, getQueuedTaskCount()); checkCompletedNormally(f); @@ -727,7 +748,7 @@ public class CountedCompleterTest extend * invoke task throws exception when task completes abnormally */ public void testAbnormalInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); try { @@ -744,7 +765,7 @@ public class CountedCompleterTest extend * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); f.quietlyInvoke(); @@ -758,7 +779,7 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -776,7 +797,7 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -796,7 +817,7 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -816,7 +837,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -831,7 +852,7 @@ public class CountedCompleterTest extend * invoke task throws exception when task cancelled */ public void testCancelledInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -849,7 +870,7 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -868,7 +889,7 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -887,7 +908,7 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGet() throws Exception { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -906,7 +927,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -922,7 +943,7 @@ public class CountedCompleterTest extend */ public void testGetPool() { final ForkJoinPool mainPool = mainPool(); - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertSame(mainPool, getPool()); }}; @@ -933,7 +954,7 @@ public class CountedCompleterTest extend * getPool of non-FJ task returns null */ public void testGetPool2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertNull(getPool()); }}; @@ -944,7 +965,7 @@ public class CountedCompleterTest extend * inForkJoinPool of executing task returns true */ public void testInForkJoinPool() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertTrue(inForkJoinPool()); }}; @@ -955,7 +976,7 @@ public class CountedCompleterTest extend * inForkJoinPool of non-FJ task returns false */ public void testInForkJoinPool2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertFalse(inForkJoinPool()); }}; @@ -966,7 +987,7 @@ public class CountedCompleterTest extend * setRawResult(null) succeeds */ public void testSetRawResult() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { setRawResult(null); assertNull(getRawResult()); @@ -978,7 +999,7 @@ public class CountedCompleterTest extend * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionally2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF n = new LCCF(8); CCF f = new LCCF(n, 8); @@ -994,7 +1015,7 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1011,7 +1032,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); invokeAll(f); @@ -1025,7 +1046,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1045,12 +1066,12 @@ public class CountedCompleterTest extend * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollection() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet set = new HashSet(); set.add(f); set.add(g); set.add(h); @@ -1069,7 +1090,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPE() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1086,7 +1107,7 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1104,7 +1125,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF g = new LFCCF(9); try { @@ -1121,7 +1142,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1140,12 +1161,12 @@ public class CountedCompleterTest extend * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollection() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet>(); set.add(f); set.add(g); set.add(h); @@ -1164,7 +1185,7 @@ public class CountedCompleterTest extend * and suppresses execution */ public void testTryUnfork() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1183,7 +1204,7 @@ public class CountedCompleterTest extend * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF h = new LCCF(7); assertSame(h, h.fork()); @@ -1205,7 +1226,7 @@ public class CountedCompleterTest extend * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1225,7 +1246,7 @@ public class CountedCompleterTest extend * executing it */ public void testPollNextLocalTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1244,7 +1265,7 @@ public class CountedCompleterTest extend * pollTask returns an unexecuted task without executing it */ public void testPollTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1262,7 +1283,7 @@ public class CountedCompleterTest extend * peekNextLocalTask returns least recent unexecuted task in async mode */ public void testPeekNextLocalTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1283,7 +1304,7 @@ public class CountedCompleterTest extend * executing it, in async mode */ public void testPollNextLocalTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1303,7 +1324,7 @@ public class CountedCompleterTest extend * async mode */ public void testPollTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1326,7 +1347,7 @@ public class CountedCompleterTest extend * completed tasks; getRawResult returns null. */ public void testInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertNull(f.invoke()); @@ -1342,7 +1363,7 @@ public class CountedCompleterTest extend * completed tasks */ public void testQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); f.quietlyInvoke(); @@ -1356,7 +1377,7 @@ public class CountedCompleterTest extend * join of a forked task returns when task completes */ public void testForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1371,7 +1392,7 @@ public class CountedCompleterTest extend * get of a forked task returns when task completes */ public void testForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1386,7 +1407,7 @@ public class CountedCompleterTest extend * timed get of a forked task returns when task completes */ public void testForkTimedGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1401,12 +1422,12 @@ public class CountedCompleterTest extend * timed get with null time unit throws NPE */ public void testForkTimedGetNPESingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); try { - f.get(5L, null); + f.get(randomTimeout(), null); shouldThrow(); } catch (NullPointerException success) {} }}; @@ -1417,7 +1438,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1433,7 +1454,7 @@ public class CountedCompleterTest extend * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesceSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1449,7 +1470,7 @@ public class CountedCompleterTest extend * invoke task throws exception when task completes abnormally */ public void testAbnormalInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); try { @@ -1466,7 +1487,7 @@ public class CountedCompleterTest extend * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); f.quietlyInvoke(); @@ -1480,7 +1501,7 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1498,7 +1519,7 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1518,7 +1539,7 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1538,7 +1559,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1553,7 +1574,7 @@ public class CountedCompleterTest extend * invoke task throws exception when task cancelled */ public void testCancelledInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1571,7 +1592,7 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1590,7 +1611,7 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task cancelled */ public void testCancelledForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1609,7 +1630,7 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGetSingleton() throws Exception { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1628,7 +1649,7 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1643,7 +1664,7 @@ public class CountedCompleterTest extend * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionallySingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF n = new LCCF(8); CCF f = new LCCF(n, 8); @@ -1659,7 +1680,7 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1676,7 +1697,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); invokeAll(f); @@ -1690,7 +1711,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1710,12 +1731,12 @@ public class CountedCompleterTest extend * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet>(); set.add(f); set.add(g); set.add(h); @@ -1734,7 +1755,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPESingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1751,7 +1772,7 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1769,7 +1790,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF g = new LFCCF(9); try { @@ -1786,7 +1807,7 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1805,12 +1826,12 @@ public class CountedCompleterTest extend * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet>(); set.add(f); set.add(g); set.add(h);