--- jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java 2009/11/16 04:57:10 1.3 +++ jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java 2009/11/16 05:30:08 1.4 @@ -93,7 +93,7 @@ public class ThreadPoolExecutorSubclassT finally { lock.unlock(); } } public V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException{ + throws InterruptedException, ExecutionException, TimeoutException { long nanos = unit.toNanos(timeout); lock.lock(); try { @@ -176,9 +176,9 @@ public class ThreadPoolExecutorSubclassT } - static class FailingThreadFactory implements ThreadFactory{ + static class FailingThreadFactory implements ThreadFactory { int calls = 0; - public Thread newThread(Runnable r){ + public Thread newThread(Runnable r) { if (++calls > 1) return null; return new Thread(r); } @@ -195,13 +195,13 @@ public class ThreadPoolExecutorSubclassT public void run() { try { Thread.sleep(SHORT_DELAY_MS); - } catch (InterruptedException e){ + } catch (InterruptedException e) { threadUnexpectedException(); } } }); Thread.sleep(SMALL_DELAY_MS); - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); } joinPool(p1); @@ -217,7 +217,7 @@ public class ThreadPoolExecutorSubclassT p2.execute(new MediumRunnable()); try { Thread.sleep(SHORT_DELAY_MS); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } assertEquals(1, p2.getActiveCount()); @@ -262,7 +262,7 @@ public class ThreadPoolExecutorSubclassT p2.execute(new ShortRunnable()); try { Thread.sleep(SMALL_DELAY_MS); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } assertEquals(1, p2.getCompletedTaskCount()); @@ -375,7 +375,7 @@ public class ThreadPoolExecutorSubclassT p2.execute(new MediumRunnable()); Thread.sleep(SHORT_DELAY_MS); assertEquals(2, p2.getLargestPoolSize()); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } joinPool(p2); @@ -413,7 +413,7 @@ public class ThreadPoolExecutorSubclassT p1.execute(new MediumRunnable()); Thread.sleep(SHORT_DELAY_MS); assertEquals(1, p1.getTaskCount()); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } joinPool(p1); @@ -446,7 +446,7 @@ public class ThreadPoolExecutorSubclassT try { assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); assertTrue(p1.isTerminated()); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -467,7 +467,7 @@ public class ThreadPoolExecutorSubclassT assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); assertTrue(p1.isTerminated()); assertFalse(p1.isTerminating()); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -479,7 +479,7 @@ public class ThreadPoolExecutorSubclassT BlockingQueue q = new ArrayBlockingQueue(10); ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); FutureTask[] tasks = new FutureTask[5]; - for (int i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); p1.execute(tasks[i]); } @@ -506,7 +506,7 @@ public class ThreadPoolExecutorSubclassT BlockingQueue q = new ArrayBlockingQueue(10); ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); FutureTask[] tasks = new FutureTask[5]; - for (int i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); p1.execute(tasks[i]); } @@ -534,7 +534,7 @@ public class ThreadPoolExecutorSubclassT public void testPurge() { ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); FutureTask[] tasks = new FutureTask[5]; - for (int i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); p1.execute(tasks[i]); } @@ -577,7 +577,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -588,7 +588,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -599,7 +599,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -610,7 +610,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -621,7 +621,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -632,7 +632,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } @@ -644,7 +644,7 @@ public class ThreadPoolExecutorSubclassT try { new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); - } catch (IllegalArgumentException success){} + } catch (IllegalArgumentException success) {} } /** @@ -655,7 +655,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -666,7 +666,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -677,7 +677,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -688,7 +688,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -699,7 +699,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory()); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } /** @@ -711,7 +711,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } @@ -723,7 +723,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -734,7 +734,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -745,7 +745,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -756,7 +756,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -767,7 +767,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -778,7 +778,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler()); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } /** @@ -790,7 +790,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),r); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } @@ -802,7 +802,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -813,7 +813,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -824,7 +824,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -835,7 +835,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -846,7 +846,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (IllegalArgumentException success){} + catch (IllegalArgumentException success) {} } /** @@ -857,7 +857,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } /** @@ -869,7 +869,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),new SimpleThreadFactory(),r); shouldThrow(); } - catch (NullPointerException success){} + catch (NullPointerException success) {} } /** @@ -881,7 +881,7 @@ public class ThreadPoolExecutorSubclassT new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f,new NoOpREHandler()); shouldThrow(); } - catch (NullPointerException successdn8){} + catch (NullPointerException successdn8) {} } @@ -893,11 +893,11 @@ public class ThreadPoolExecutorSubclassT ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1)); try { - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { p.execute(new MediumRunnable()); } shouldThrow(); - } catch (RejectedExecutionException success){} + } catch (RejectedExecutionException success) {} joinPool(p); } @@ -910,19 +910,19 @@ public class ThreadPoolExecutorSubclassT try { TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { tasks[i] = new TrackedNoOpRunnable(); } TrackedLongRunnable mr = new TrackedLongRunnable(); p.execute(mr); - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { p.execute(tasks[i]); } for (int i = 1; i < 5; ++i) { assertTrue(tasks[i].done); } try { p.shutdownNow(); } catch (SecurityException ok) { return; } - } catch (RejectedExecutionException ex){ + } catch (RejectedExecutionException ex) { unexpectedException(); } finally { joinPool(p); @@ -938,18 +938,18 @@ public class ThreadPoolExecutorSubclassT try { TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { tasks[i] = new TrackedNoOpRunnable(); } p.execute(new TrackedLongRunnable()); - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { p.execute(tasks[i]); } - for (int i = 0; i < 5; ++i){ + for (int i = 0; i < 5; ++i) { assertFalse(tasks[i].done); } try { p.shutdownNow(); } catch (SecurityException ok) { return; } - } catch (RejectedExecutionException ex){ + } catch (RejectedExecutionException ex) { unexpectedException(); } finally { joinPool(p); @@ -972,7 +972,7 @@ public class ThreadPoolExecutorSubclassT assertFalse(p.getQueue().contains(r2)); assertTrue(p.getQueue().contains(r3)); try { p.shutdownNow(); } catch (SecurityException ok) { return; } - } catch (RejectedExecutionException ex){ + } catch (RejectedExecutionException ex) { unexpectedException(); } finally { joinPool(p); @@ -989,7 +989,7 @@ public class ThreadPoolExecutorSubclassT try { tpe.execute(new NoOpRunnable()); shouldThrow(); - } catch (RejectedExecutionException success){} + } catch (RejectedExecutionException success) {} joinPool(tpe); } @@ -1006,7 +1006,7 @@ public class ThreadPoolExecutorSubclassT TrackedNoOpRunnable r = new TrackedNoOpRunnable(); p.execute(r); assertFalse(r.done); - } catch (RejectedExecutionException success){ + } catch (RejectedExecutionException success) { unexpectedException(); } finally { joinPool(p); @@ -1025,7 +1025,7 @@ public class ThreadPoolExecutorSubclassT TrackedNoOpRunnable r = new TrackedNoOpRunnable(); p.execute(r); assertFalse(r.done); - } catch (RejectedExecutionException success){ + } catch (RejectedExecutionException success) { unexpectedException(); } finally { joinPool(p); @@ -1045,7 +1045,7 @@ public class ThreadPoolExecutorSubclassT TrackedNoOpRunnable r = new TrackedNoOpRunnable(); p.execute(r); assertFalse(r.done); - } catch (RejectedExecutionException success){ + } catch (RejectedExecutionException success) { unexpectedException(); } finally { joinPool(p); @@ -1062,7 +1062,7 @@ public class ThreadPoolExecutorSubclassT tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); tpe.execute(null); shouldThrow(); - } catch (NullPointerException success){} + } catch (NullPointerException success) {} joinPool(tpe); } @@ -1074,11 +1074,11 @@ public class ThreadPoolExecutorSubclassT ThreadPoolExecutor tpe = null; try { tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e){} + } catch (Exception e) {} try { tpe.setCorePoolSize(-1); shouldThrow(); - } catch (IllegalArgumentException success){ + } catch (IllegalArgumentException success) { } finally { try { tpe.shutdown(); } catch (SecurityException ok) { return; } } @@ -1093,11 +1093,11 @@ public class ThreadPoolExecutorSubclassT ThreadPoolExecutor tpe = null; try { tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e){} + } catch (Exception e) {} try { tpe.setMaximumPoolSize(1); shouldThrow(); - } catch (IllegalArgumentException success){ + } catch (IllegalArgumentException success) { } finally { try { tpe.shutdown(); } catch (SecurityException ok) { return; } } @@ -1112,11 +1112,11 @@ public class ThreadPoolExecutorSubclassT ThreadPoolExecutor tpe = null; try { tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e){} + } catch (Exception e) {} try { tpe.setMaximumPoolSize(-1); shouldThrow(); - } catch (IllegalArgumentException success){ + } catch (IllegalArgumentException success) { } finally { try { tpe.shutdown(); } catch (SecurityException ok) { return; } } @@ -1132,12 +1132,12 @@ public class ThreadPoolExecutorSubclassT ThreadPoolExecutor tpe = null; try { tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e){} + } catch (Exception e) {} try { tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); shouldThrow(); - } catch (IllegalArgumentException success){ + } catch (IllegalArgumentException success) { } finally { try { tpe.shutdown(); } catch (SecurityException ok) { return; } } @@ -1688,7 +1688,7 @@ public class ThreadPoolExecutorSubclassT try { Thread.sleep(MEDIUM_DELAY_MS); assertEquals(0, tpe.getPoolSize()); - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); } finally { joinPool(tpe); @@ -1705,7 +1705,7 @@ public class ThreadPoolExecutorSubclassT try { Thread.sleep(MEDIUM_DELAY_MS); assertTrue(tpe.getPoolSize() >= 1); - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); } finally { joinPool(tpe);