--- jsr166/src/test/tck/ExecutorCompletionServiceTest.java 2017/12/03 17:15:21 1.29 +++ jsr166/src/test/tck/ExecutorCompletionServiceTest.java 2021/01/26 13:33:06 1.30 @@ -38,7 +38,7 @@ public class ExecutorCompletionServiceTe */ public void testConstructorNPE() { try { - new ExecutorCompletionService(null); + new ExecutorCompletionService(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -48,7 +48,7 @@ public class ExecutorCompletionServiceTe */ public void testConstructorNPE2() { try { - new ExecutorCompletionService(cachedThreadPool, null); + new ExecutorCompletionService(cachedThreadPool, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -57,9 +57,9 @@ public class ExecutorCompletionServiceTe * ecs.submit(null) throws NullPointerException */ public void testSubmitNullCallable() { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); try { - cs.submit((Callable) null); + cs.submit((Callable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -68,7 +68,7 @@ public class ExecutorCompletionServiceTe * ecs.submit(null, val) throws NullPointerException */ public void testSubmitNullRunnable() { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); try { cs.submit((Runnable) null, Boolean.TRUE); shouldThrow(); @@ -79,9 +79,9 @@ public class ExecutorCompletionServiceTe * A taken submitted task is completed */ public void testTake() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); cs.submit(new StringTask()); - Future f = cs.take(); + Future f = cs.take(); assertTrue(f.isDone()); assertSame(TEST_STRING, f.get()); } @@ -90,9 +90,9 @@ public class ExecutorCompletionServiceTe * Take returns the same future object returned by submit */ public void testTake2() throws InterruptedException { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); - Future f1 = cs.submit(new StringTask()); - Future f2 = cs.take(); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + Future f1 = cs.submit(new StringTask()); + Future f2 = cs.take(); assertSame(f1, f2); } @@ -100,12 +100,12 @@ public class ExecutorCompletionServiceTe * poll returns non-null when the returned task is completed */ public void testPoll1() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); assertNull(cs.poll()); cs.submit(new StringTask()); long startTime = System.nanoTime(); - Future f; + Future f; while ((f = cs.poll()) == null) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) fail("timed out"); @@ -119,12 +119,12 @@ public class ExecutorCompletionServiceTe * timed poll returns non-null when the returned task is completed */ public void testPoll2() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); assertNull(cs.poll()); cs.submit(new StringTask()); long startTime = System.nanoTime(); - Future f; + Future f; while ((f = cs.poll(timeoutMillis(), MILLISECONDS)) == null) { assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); if (millisElapsedSince(startTime) > LONG_DELAY_MS) @@ -139,9 +139,9 @@ public class ExecutorCompletionServiceTe * poll returns null before the returned task is completed */ public void testPollReturnsNullBeforeCompletion() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); final CountDownLatch proceed = new CountDownLatch(1); - cs.submit(new Callable() { public String call() throws Exception { + cs.submit(new Callable() { public String call() throws Exception { await(proceed); return TEST_STRING; }}); @@ -159,7 +159,7 @@ public class ExecutorCompletionServiceTe * successful and failed tasks are both returned */ public void testTaskAssortment() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService(cachedThreadPool); ArithmeticException ex = new ArithmeticException(); final int rounds = 2; for (int i = rounds; i--> 0; ) { @@ -204,10 +204,10 @@ public class ExecutorCompletionServiceTe try (PoolCleaner cleaner = cleaner(e)) { assertNull(cs.poll()); Callable c = new StringTask(); - Future f1 = cs.submit(c); + Future f1 = cs.submit(c); assertTrue("submit must return MyCallableFuture", f1 instanceof MyCallableFuture); - Future f2 = cs.take(); + Future f2 = cs.take(); assertSame("submit and take must return same objects", f1, f2); assertTrue("completed task must have set done", done.get()); } @@ -234,10 +234,10 @@ public class ExecutorCompletionServiceTe try (PoolCleaner cleaner = cleaner(e)) { assertNull(cs.poll()); Runnable r = new NoOpRunnable(); - Future f1 = cs.submit(r, null); + Future f1 = cs.submit(r, null); assertTrue("submit must return MyRunnableFuture", f1 instanceof MyRunnableFuture); - Future f2 = cs.take(); + Future f2 = cs.take(); assertSame("submit and take must return same objects", f1, f2); assertTrue("completed task must have set done", done.get()); }