--- jsr166/src/test/tck/ScheduledExecutorTest.java 2004/01/21 01:47:07 1.18 +++ jsr166/src/test/tck/ScheduledExecutorTest.java 2009/11/16 04:57:10 1.23 @@ -2,8 +2,8 @@ * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import junit.framework.*; @@ -13,7 +13,7 @@ import java.util.concurrent.atomic.*; public class ScheduledExecutorTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run (suite()); } public static Test suite() { return new TestSuite(ScheduledExecutorTest.class); @@ -30,20 +30,20 @@ public class ScheduledExecutorTest exten p1.execute(runnable); assertFalse(runnable.done); Thread.sleep(SHORT_DELAY_MS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } try { Thread.sleep(MEDIUM_DELAY_MS); - } catch(InterruptedException e){ + } catch (InterruptedException e){ unexpectedException(); } assertTrue(runnable.done); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } joinPool(p1); } - catch(Exception e){ + catch (Exception e){ unexpectedException(); } - + } @@ -59,10 +59,10 @@ public class ScheduledExecutorTest exten Thread.sleep(MEDIUM_DELAY_MS); assertTrue(callable.done); assertEquals(Boolean.TRUE, f.get()); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } joinPool(p1); - } catch(RejectedExecutionException e){} - catch(Exception e){ + } catch (RejectedExecutionException e){} + catch (Exception e){ e.printStackTrace(); unexpectedException(); } @@ -80,13 +80,13 @@ public class ScheduledExecutorTest exten assertFalse(runnable.done); Thread.sleep(MEDIUM_DELAY_MS); assertTrue(runnable.done); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } joinPool(p1); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } - + /** * scheduleAtFixedRate executes runnable after given initial delay */ @@ -100,7 +100,7 @@ public class ScheduledExecutorTest exten assertTrue(runnable.done); h.cancel(true); joinPool(p1); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } @@ -123,11 +123,11 @@ public class ScheduledExecutorTest exten assertTrue(runnable.done); h.cancel(true); joinPool(p1); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } - + /** * scheduleAtFixedRate executes series of tasks at given rate */ @@ -135,7 +135,7 @@ public class ScheduledExecutorTest exten try { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); RunnableCounter counter = new RunnableCounter(); - ScheduledFuture h = + ScheduledFuture h = p1.scheduleAtFixedRate(counter, 0, 1, TimeUnit.MILLISECONDS); Thread.sleep(SMALL_DELAY_MS); h.cancel(true); @@ -144,9 +144,8 @@ public class ScheduledExecutorTest exten // an execution per SHORT delay, but no more than one SHORT more assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); - assertTrue(h.isDone()); joinPool(p1); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } @@ -158,16 +157,15 @@ public class ScheduledExecutorTest exten try { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); RunnableCounter counter = new RunnableCounter(); - ScheduledFuture h = + ScheduledFuture h = p1.scheduleWithFixedDelay(counter, 0, 1, TimeUnit.MILLISECONDS); Thread.sleep(SMALL_DELAY_MS); h.cancel(true); int c = counter.count.get(); assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); - assertTrue(h.isDone()); joinPool(p1); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } @@ -182,11 +180,11 @@ public class ScheduledExecutorTest exten se = new ScheduledThreadPoolExecutor(1); se.execute(null); shouldThrow(); - } catch(NullPointerException success){} - catch(Exception e){ + } catch (NullPointerException success){} + catch (Exception e){ unexpectedException(); } - + joinPool(se); } @@ -199,13 +197,13 @@ public class ScheduledExecutorTest exten TrackedCallable callable = null; Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(NullPointerException success){} - catch(Exception e){ + } catch (NullPointerException success){} + catch (Exception e){ unexpectedException(); } joinPool(se); } - + /** * execute throws RejectedExecutionException if shutdown */ @@ -216,10 +214,10 @@ public class ScheduledExecutorTest exten se.schedule(new NoOpRunnable(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(RejectedExecutionException success){ + } catch (RejectedExecutionException success){ } catch (SecurityException ok) { } - + joinPool(se); } @@ -234,7 +232,7 @@ public class ScheduledExecutorTest exten se.schedule(new NoOpCallable(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(RejectedExecutionException success){ + } catch (RejectedExecutionException success){ } catch (SecurityException ok) { } joinPool(se); @@ -250,7 +248,7 @@ public class ScheduledExecutorTest exten se.schedule(new NoOpCallable(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(RejectedExecutionException success){ + } catch (RejectedExecutionException success){ } catch (SecurityException ok) { } joinPool(se); @@ -266,12 +264,12 @@ public class ScheduledExecutorTest exten se.scheduleAtFixedRate(new NoOpRunnable(), MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(RejectedExecutionException success){ + } catch (RejectedExecutionException success){ } catch (SecurityException ok) { - } + } joinPool(se); } - + /** * scheduleWithFixedDelay throws RejectedExecutionException if shutdown */ @@ -282,9 +280,9 @@ public class ScheduledExecutorTest exten se.scheduleWithFixedDelay(new NoOpRunnable(), MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); shouldThrow(); - } catch(RejectedExecutionException success){ + } catch (RejectedExecutionException success){ } catch (SecurityException ok) { - } + } joinPool(se); } @@ -298,13 +296,13 @@ public class ScheduledExecutorTest exten p2.execute(new SmallRunnable()); try { Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } assertEquals(1, p2.getActiveCount()); joinPool(p2); } - + /** * getCompletedTaskCount increases, but doesn't overestimate, * when tasks complete @@ -315,22 +313,22 @@ public class ScheduledExecutorTest exten p2.execute(new SmallRunnable()); try { Thread.sleep(MEDIUM_DELAY_MS); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } assertEquals(1, p2.getCompletedTaskCount()); joinPool(p2); } - + /** - * getCorePoolSize returns size given in constructor if not otherwise set + * getCorePoolSize returns size given in constructor if not otherwise set */ public void testGetCorePoolSize() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); assertEquals(1, p1.getCorePoolSize()); joinPool(p1); } - + /** * getLargestPoolSize increases, but doesn't overestimate, when * multiple threads active @@ -342,13 +340,13 @@ public class ScheduledExecutorTest exten p2.execute(new SmallRunnable()); try { Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } assertEquals(2, p2.getLargestPoolSize()); joinPool(p2); } - + /** * getPoolSize increases, but doesn't overestimate, when threads * become active @@ -360,7 +358,7 @@ public class ScheduledExecutorTest exten assertEquals(1, p1.getPoolSize()); joinPool(p1); } - + /** * getTaskCount increases, but doesn't overestimate, when tasks * submitted @@ -368,18 +366,18 @@ public class ScheduledExecutorTest exten public void testGetTaskCount() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); assertEquals(0, p1.getTaskCount()); - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) p1.execute(new SmallRunnable()); try { Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } assertEquals(5, p1.getTaskCount()); joinPool(p1); } - /** + /** * getThreadFactory returns factory in constructor if not set */ public void testGetThreadFactory() { @@ -389,7 +387,7 @@ public class ScheduledExecutorTest exten joinPool(p); } - /** + /** * setThreadFactory sets the thread factory returned by getThreadFactory */ public void testSetThreadFactory() { @@ -400,7 +398,7 @@ public class ScheduledExecutorTest exten joinPool(p); } - /** + /** * setThreadFactory(null) throws NPE */ public void testSetThreadFactoryNull() { @@ -413,23 +411,23 @@ public class ScheduledExecutorTest exten joinPool(p); } } - + /** * is isShutDown is false before shutdown, true after */ public void testIsShutdown() { - + ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); try { assertFalse(p1.isShutdown()); } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } } assertTrue(p1.isShutdown()); } - + /** * isTerminated is false before termination, true after */ @@ -438,14 +436,14 @@ public class ScheduledExecutorTest exten try { p1.execute(new SmallRunnable()); } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } } try { assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); assertTrue(p1.isTerminated()); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); - } + } } /** @@ -458,15 +456,15 @@ public class ScheduledExecutorTest exten p1.execute(new SmallRunnable()); assertFalse(p1.isTerminating()); } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } } try { assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); assertTrue(p1.isTerminated()); assertFalse(p1.isTerminating()); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); - } + } } /** @@ -475,7 +473,7 @@ public class ScheduledExecutorTest exten public void testGetQueue() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++){ tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); } try { @@ -483,7 +481,7 @@ public class ScheduledExecutorTest exten BlockingQueue q = p1.getQueue(); assertTrue(q.contains(tasks[4])); assertFalse(q.contains(tasks[0])); - } catch(Exception e) { + } catch (Exception e) { unexpectedException(); } finally { joinPool(p1); @@ -496,7 +494,7 @@ public class ScheduledExecutorTest exten public void testRemove() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++){ tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); } try { @@ -511,7 +509,7 @@ public class ScheduledExecutorTest exten assertTrue(q.contains((Runnable)tasks[3])); assertTrue(p1.remove((Runnable)tasks[3])); assertFalse(q.contains((Runnable)tasks[3])); - } catch(Exception e) { + } catch (Exception e) { unexpectedException(); } finally { joinPool(p1); @@ -524,16 +522,29 @@ public class ScheduledExecutorTest exten public void testPurge() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); + for (int i = 0; i < 5; i++){ + tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); + } + try { + int max = 5; + if (tasks[4].cancel(true)) --max; + if (tasks[3].cancel(true)) --max; + // There must eventually be an interference-free point at + // which purge will not fail. (At worst, when queue is empty.) + int k; + for (k = 0; k < SMALL_DELAY_MS; ++k) { + p1.purge(); + long count = p1.getTaskCount(); + if (count >= 0 && count <= max) + break; + Thread.sleep(1); + } + assertTrue(k < SMALL_DELAY_MS); + } catch (Exception e) { + unexpectedException(); + } finally { + joinPool(p1); } - int max = 5; - if (tasks[4].cancel(true)) --max; - if (tasks[3].cancel(true)) --max; - p1.purge(); - long count = p1.getTaskCount(); - assertTrue(count > 0 && count <= max); - joinPool(p1); } /** @@ -541,12 +552,12 @@ public class ScheduledExecutorTest exten */ public void testShutDownNow() { ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); List l; try { l = p1.shutdownNow(); - } catch (SecurityException ok) { + } catch (SecurityException ok) { return; } assertTrue(p1.isShutdown()); @@ -565,9 +576,9 @@ public class ScheduledExecutorTest exten assertFalse(p1.getContinueExistingPeriodicTasksAfterShutdownPolicy()); ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } BlockingQueue q = p1.getQueue(); for (Iterator it = q.iterator(); it.hasNext();) { ScheduledFuture t = (ScheduledFuture)it.next(); @@ -579,9 +590,9 @@ public class ScheduledExecutorTest exten assertTrue(tasks[i].isDone()); assertFalse(tasks[i].isCancelled()); } - + } - catch(Exception ex) { + catch (Exception ex) { unexpectedException(); } } @@ -596,16 +607,16 @@ public class ScheduledExecutorTest exten ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); p1.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } assertTrue(p1.isShutdown()); BlockingQueue q = p1.getQueue(); assertTrue(q.isEmpty()); Thread.sleep(SMALL_DELAY_MS); assertTrue(p1.isTerminated()); } - catch(Exception ex) { + catch (Exception ex) { unexpectedException(); } } @@ -621,14 +632,14 @@ public class ScheduledExecutorTest exten p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); ScheduledFuture task = p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } assertTrue(p1.isShutdown()); BlockingQueue q = p1.getQueue(); assertTrue(q.isEmpty()); Thread.sleep(SHORT_DELAY_MS); assertTrue(p1.isTerminated()); } - catch(Exception ex) { + catch (Exception ex) { unexpectedException(); } } @@ -644,7 +655,7 @@ public class ScheduledExecutorTest exten ScheduledFuture task = p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS); assertFalse(task.isCancelled()); - try { p1.shutdown(); } catch(SecurityException ok) { return; } + try { p1.shutdown(); } catch (SecurityException ok) { return; } assertFalse(task.isCancelled()); assertFalse(p1.isTerminated()); assertTrue(p1.isShutdown()); @@ -655,10 +666,10 @@ public class ScheduledExecutorTest exten Thread.sleep(SHORT_DELAY_MS); assertTrue(p1.isTerminated()); } - catch(Exception ex) { + catch (Exception ex) { unexpectedException(); } - finally { + finally { joinPool(p1); } } @@ -731,7 +742,7 @@ public class ScheduledExecutorTest exten try { e.invokeAny(null); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -746,7 +757,7 @@ public class ScheduledExecutorTest exten try { e.invokeAny(new ArrayList>()); } catch (IllegalArgumentException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -764,7 +775,7 @@ public class ScheduledExecutorTest exten l.add(null); e.invokeAny(l); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -781,7 +792,7 @@ public class ScheduledExecutorTest exten l.add(new NPETask()); e.invokeAny(l); } catch (ExecutionException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -800,7 +811,7 @@ public class ScheduledExecutorTest exten String result = e.invokeAny(l); assertSame(TEST_STRING, result); } catch (ExecutionException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -815,7 +826,7 @@ public class ScheduledExecutorTest exten try { e.invokeAll(null); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -830,7 +841,7 @@ public class ScheduledExecutorTest exten try { List> r = e.invokeAll(new ArrayList>()); assertTrue(r.isEmpty()); - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -848,7 +859,7 @@ public class ScheduledExecutorTest exten l.add(null); e.invokeAll(l); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -865,10 +876,10 @@ public class ScheduledExecutorTest exten l.add(new NPETask()); List> result = e.invokeAll(l); assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) + for (Iterator> it = result.iterator(); it.hasNext();) it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { + } catch (ExecutionException success) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -886,10 +897,10 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); List> result = e.invokeAll(l); assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) + for (Iterator> it = result.iterator(); it.hasNext();) assertSame(TEST_STRING, it.next().get()); } catch (ExecutionException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -904,7 +915,7 @@ public class ScheduledExecutorTest exten try { e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -921,7 +932,7 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); e.invokeAny(l, MEDIUM_DELAY_MS, null); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -936,7 +947,7 @@ public class ScheduledExecutorTest exten try { e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } catch (IllegalArgumentException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -954,7 +965,7 @@ public class ScheduledExecutorTest exten l.add(null); e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); unexpectedException(); } finally { @@ -971,8 +982,8 @@ public class ScheduledExecutorTest exten ArrayList> l = new ArrayList>(); l.add(new NPETask()); e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch(ExecutionException success) { - } catch(Exception ex) { + } catch (ExecutionException success) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -991,7 +1002,7 @@ public class ScheduledExecutorTest exten String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); assertSame(TEST_STRING, result); } catch (ExecutionException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1006,7 +1017,7 @@ public class ScheduledExecutorTest exten try { e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1023,7 +1034,7 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); e.invokeAll(l, MEDIUM_DELAY_MS, null); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1038,7 +1049,7 @@ public class ScheduledExecutorTest exten try { List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); assertTrue(r.isEmpty()); - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1056,7 +1067,7 @@ public class ScheduledExecutorTest exten l.add(null); e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } catch (NullPointerException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1073,10 +1084,10 @@ public class ScheduledExecutorTest exten l.add(new NPETask()); List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) + for (Iterator> it = result.iterator(); it.hasNext();) it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { + } catch (ExecutionException success) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1094,10 +1105,10 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) + for (Iterator> it = result.iterator(); it.hasNext();) assertSame(TEST_STRING, it.next().get()); } catch (ExecutionException success) { - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e); @@ -1116,7 +1127,7 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); List> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); assertEquals(3, result.size()); - Iterator> it = result.iterator(); + Iterator> it = result.iterator(); Future f1 = it.next(); Future f2 = it.next(); Future f3 = it.next(); @@ -1125,7 +1136,7 @@ public class ScheduledExecutorTest exten assertTrue(f3.isDone()); assertFalse(f1.isCancelled()); assertTrue(f2.isCancelled()); - } catch(Exception ex) { + } catch (Exception ex) { unexpectedException(); } finally { joinPool(e);