ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.72 by jsr166, Sun Oct 4 02:38:45 2015 UTC vs.
Revision 1.80 by jsr166, Sun Oct 4 06:39:13 2015 UTC

# Line 272 | Line 272 | public class ThreadPoolExecutorSubclassT
272       * prestartCoreThread starts a thread if under corePoolSize, else doesn't
273       */
274      public void testPrestartCoreThread() {
275 <        ThreadPoolExecutor p =
275 >        final ThreadPoolExecutor p =
276              new CustomTPE(2, 6,
277                            LONG_DELAY_MS, MILLISECONDS,
278                            new ArrayBlockingQueue<Runnable>(10));
# Line 298 | Line 298 | public class ThreadPoolExecutorSubclassT
298       * prestartAllCoreThreads starts all corePoolSize threads
299       */
300      public void testPrestartAllCoreThreads() {
301 <        ThreadPoolExecutor p =
301 >        final ThreadPoolExecutor p =
302              new CustomTPE(2, 6,
303                            LONG_DELAY_MS, MILLISECONDS,
304                            new ArrayBlockingQueue<Runnable>(10));
# Line 752 | Line 752 | public class ThreadPoolExecutorSubclassT
752          final int poolSize = 2;
753          final int count = 5;
754          final AtomicInteger ran = new AtomicInteger(0);
755 <        ThreadPoolExecutor p =
755 >        final ThreadPoolExecutor p =
756              new CustomTPE(poolSize, poolSize, LONG_DELAY_MS, MILLISECONDS,
757                            new ArrayBlockingQueue<Runnable>(10));
758          CountDownLatch threadsStarted = new CountDownLatch(poolSize);
# Line 1124 | Line 1124 | public class ThreadPoolExecutorSubclassT
1124       * execute throws RejectedExecutionException if saturated.
1125       */
1126      public void testSaturatedExecute() {
1127 <        ThreadPoolExecutor p =
1127 >        final ThreadPoolExecutor p =
1128              new CustomTPE(1, 1,
1129                            LONG_DELAY_MS, MILLISECONDS,
1130                            new ArrayBlockingQueue<Runnable>(1));
1131 <        final CountDownLatch done = new CountDownLatch(1);
1132 <        try {
1131 >        try (PoolCleaner cleaner = cleaner(p)) {
1132 >            final CountDownLatch done = new CountDownLatch(1);
1133              Runnable task = new CheckedRunnable() {
1134                  public void realRun() throws InterruptedException {
1135                      done.await();
# Line 1143 | Line 1143 | public class ThreadPoolExecutorSubclassT
1143                  } catch (RejectedExecutionException success) {}
1144                  assertTrue(p.getTaskCount() <= 2);
1145              }
1146        } finally {
1146              done.countDown();
1148            joinPool(p);
1147          }
1148      }
1149  
# Line 1153 | Line 1151 | public class ThreadPoolExecutorSubclassT
1151       * executor using CallerRunsPolicy runs task if saturated.
1152       */
1153      public void testSaturatedExecute2() {
1154 <        RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
1155 <        ThreadPoolExecutor p = new CustomTPE(1, 1,
1156 <                                             LONG_DELAY_MS, MILLISECONDS,
1157 <                                             new ArrayBlockingQueue<Runnable>(1),
1158 <                                             h);
1159 <        try {
1154 >        final ThreadPoolExecutor p =
1155 >            new CustomTPE(1, 1,
1156 >                          LONG_DELAY_MS, MILLISECONDS,
1157 >                          new ArrayBlockingQueue<Runnable>(1),
1158 >                          new CustomTPE.CallerRunsPolicy());
1159 >        try (PoolCleaner cleaner = cleaner(p)) {
1160 >            final CountDownLatch done = new CountDownLatch(1);
1161 >            Runnable blocker = new CheckedRunnable() {
1162 >                public void realRun() throws InterruptedException {
1163 >                    done.await();
1164 >                }};
1165 >            p.execute(blocker);
1166              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
1167 <            for (int i = 0; i < tasks.length; ++i)
1167 >            for (int i = 0; i < tasks.length; i++)
1168                  tasks[i] = new TrackedNoOpRunnable();
1169 <            TrackedLongRunnable mr = new TrackedLongRunnable();
1166 <            p.execute(mr);
1167 <            for (int i = 0; i < tasks.length; ++i)
1169 >            for (int i = 0; i < tasks.length; i++)
1170                  p.execute(tasks[i]);
1171 <            for (int i = 1; i < tasks.length; ++i)
1171 >            for (int i = 1; i < tasks.length; i++)
1172                  assertTrue(tasks[i].done);
1173 <            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
1174 <        } finally {
1173 <            joinPool(p);
1173 >            assertFalse(tasks[0].done); // waiting in queue
1174 >            done.countDown();
1175          }
1176      }
1177  
# Line 1178 | Line 1179 | public class ThreadPoolExecutorSubclassT
1179       * executor using DiscardPolicy drops task if saturated.
1180       */
1181      public void testSaturatedExecute3() {
1182 <        RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
1183 <        ThreadPoolExecutor p =
1182 >        final TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
1183 >        for (int i = 0; i < tasks.length; ++i)
1184 >            tasks[i] = new TrackedNoOpRunnable();
1185 >        final ThreadPoolExecutor p =
1186              new CustomTPE(1, 1,
1187                            LONG_DELAY_MS, MILLISECONDS,
1188                            new ArrayBlockingQueue<Runnable>(1),
1189 <                          h);
1190 <        try {
1191 <            TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
1192 <            for (int i = 0; i < tasks.length; ++i)
1193 <                tasks[i] = new TrackedNoOpRunnable();
1191 <            p.execute(new TrackedLongRunnable());
1189 >                          new CustomTPE.DiscardPolicy());
1190 >        try (PoolCleaner cleaner = cleaner(p)) {
1191 >            final CountDownLatch done = new CountDownLatch(1);
1192 >            p.execute(awaiter(done));
1193 >
1194              for (TrackedNoOpRunnable task : tasks)
1195                  p.execute(task);
1196 <            for (TrackedNoOpRunnable task : tasks)
1197 <                assertFalse(task.done);
1198 <            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
1197 <        } finally {
1198 <            joinPool(p);
1196 >            for (int i = 1; i < tasks.length; i++)
1197 >                assertFalse(tasks[i].done);
1198 >            done.countDown();
1199          }
1200 +        for (int i = 1; i < tasks.length; i++)
1201 +            assertFalse(tasks[i].done);
1202 +        assertTrue(tasks[0].done); // was waiting in queue
1203      }
1204  
1205      /**
1206       * executor using DiscardOldestPolicy drops oldest task if saturated.
1207       */
1208      public void testSaturatedExecute4() {
1209 <        RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
1210 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1211 <        try {
1212 <            p.execute(new TrackedLongRunnable());
1213 <            TrackedLongRunnable r2 = new TrackedLongRunnable();
1209 >        final CountDownLatch done = new CountDownLatch(1);
1210 >        LatchAwaiter r1 = awaiter(done);
1211 >        LatchAwaiter r2 = awaiter(done);
1212 >        LatchAwaiter r3 = awaiter(done);
1213 >        final ThreadPoolExecutor p =
1214 >            new CustomTPE(1, 1,
1215 >                          LONG_DELAY_MS, MILLISECONDS,
1216 >                          new ArrayBlockingQueue<Runnable>(1),
1217 >                          new CustomTPE.DiscardOldestPolicy());
1218 >        try (PoolCleaner cleaner = cleaner(p)) {
1219 >            assertEquals(LatchAwaiter.NEW, r1.state);
1220 >            assertEquals(LatchAwaiter.NEW, r2.state);
1221 >            assertEquals(LatchAwaiter.NEW, r3.state);
1222 >            p.execute(r1);
1223              p.execute(r2);
1224              assertTrue(p.getQueue().contains(r2));
1213            TrackedNoOpRunnable r3 = new TrackedNoOpRunnable();
1225              p.execute(r3);
1226              assertFalse(p.getQueue().contains(r2));
1227              assertTrue(p.getQueue().contains(r3));
1228 <            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
1218 <        } finally {
1219 <            joinPool(p);
1228 >            done.countDown();
1229          }
1230 +        assertEquals(LatchAwaiter.DONE, r1.state);
1231 +        assertEquals(LatchAwaiter.NEW, r2.state);
1232 +        assertEquals(LatchAwaiter.DONE, r3.state);
1233      }
1234  
1235      /**
1236       * execute throws RejectedExecutionException if shutdown
1237       */
1238      public void testRejectedExecutionExceptionOnShutdown() {
1239 <        ThreadPoolExecutor p =
1240 <            new CustomTPE(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
1239 >        final ThreadPoolExecutor p =
1240 >            new CustomTPE(1, 1,
1241 >                          LONG_DELAY_MS, MILLISECONDS,
1242 >                          new ArrayBlockingQueue<Runnable>(1));
1243          try { p.shutdown(); } catch (SecurityException ok) { return; }
1244 <        try {
1245 <            p.execute(new NoOpRunnable());
1246 <            shouldThrow();
1247 <        } catch (RejectedExecutionException success) {}
1248 <
1249 <        joinPool(p);
1244 >        try (PoolCleaner cleaner = cleaner(p)) {
1245 >            try {
1246 >                p.execute(new NoOpRunnable());
1247 >                shouldThrow();
1248 >            } catch (RejectedExecutionException success) {}
1249 >        }
1250      }
1251  
1252      /**
1253       * execute using CallerRunsPolicy drops task on shutdown
1254       */
1255      public void testCallerRunsOnShutdown() {
1256 <        RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
1257 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1258 <
1256 >        final ThreadPoolExecutor p =
1257 >            new CustomTPE(1, 1,
1258 >                          LONG_DELAY_MS, MILLISECONDS,
1259 >                          new ArrayBlockingQueue<Runnable>(1),
1260 >                          new CustomTPE.CallerRunsPolicy());
1261          try { p.shutdown(); } catch (SecurityException ok) { return; }
1262 <        try {
1262 >        try (PoolCleaner cleaner = cleaner(p)) {
1263              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1264              p.execute(r);
1265              assertFalse(r.done);
1250        } finally {
1251            joinPool(p);
1266          }
1267      }
1268  
# Line 1256 | Line 1270 | public class ThreadPoolExecutorSubclassT
1270       * execute using DiscardPolicy drops task on shutdown
1271       */
1272      public void testDiscardOnShutdown() {
1273 <        RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
1274 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1275 <
1273 >        final ThreadPoolExecutor p =
1274 >            new CustomTPE(1, 1,
1275 >                          LONG_DELAY_MS, MILLISECONDS,
1276 >                          new ArrayBlockingQueue<Runnable>(1),
1277 >                          new CustomTPE.DiscardPolicy());
1278          try { p.shutdown(); } catch (SecurityException ok) { return; }
1279 <        try {
1279 >        try (PoolCleaner cleaner = cleaner(p)) {
1280              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1281              p.execute(r);
1282              assertFalse(r.done);
1267        } finally {
1268            joinPool(p);
1283          }
1284      }
1285  
# Line 1273 | Line 1287 | public class ThreadPoolExecutorSubclassT
1287       * execute using DiscardOldestPolicy drops task on shutdown
1288       */
1289      public void testDiscardOldestOnShutdown() {
1290 <        RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
1291 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1290 >        final ThreadPoolExecutor p =
1291 >            new CustomTPE(1, 1,
1292 >                          LONG_DELAY_MS, MILLISECONDS,
1293 >                          new ArrayBlockingQueue<Runnable>(1),
1294 >                          new CustomTPE.DiscardOldestPolicy());
1295  
1296          try { p.shutdown(); } catch (SecurityException ok) { return; }
1297 <        try {
1297 >        try (PoolCleaner cleaner = cleaner(p)) {
1298              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1299              p.execute(r);
1300              assertFalse(r.done);
1284        } finally {
1285            joinPool(p);
1301          }
1302      }
1303  
# Line 1290 | Line 1305 | public class ThreadPoolExecutorSubclassT
1305       * execute(null) throws NPE
1306       */
1307      public void testExecuteNull() {
1308 <        ThreadPoolExecutor p =
1309 <            new CustomTPE(1, 2, 1L, SECONDS,
1308 >        final ThreadPoolExecutor p =
1309 >            new CustomTPE(1, 2,
1310 >                          1L, SECONDS,
1311                            new ArrayBlockingQueue<Runnable>(10));
1312 <        try {
1313 <            p.execute(null);
1314 <            shouldThrow();
1315 <        } catch (NullPointerException success) {}
1316 <
1317 <        joinPool(p);
1312 >        try (PoolCleaner cleaner = cleaner(p)) {
1313 >            try {
1314 >                p.execute(null);
1315 >                shouldThrow();
1316 >            } catch (NullPointerException success) {}
1317 >        }
1318      }
1319  
1320      /**
1321       * setCorePoolSize of negative value throws IllegalArgumentException
1322       */
1323      public void testCorePoolSizeIllegalArgumentException() {
1324 <        ThreadPoolExecutor p =
1324 >        final ThreadPoolExecutor p =
1325              new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1326          try {
1327              p.setCorePoolSize(-1);
# Line 1322 | Line 1338 | public class ThreadPoolExecutorSubclassT
1338       * if given a value less the core pool size
1339       */
1340      public void testMaximumPoolSizeIllegalArgumentException() {
1341 <        ThreadPoolExecutor p =
1341 >        final ThreadPoolExecutor p =
1342              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1343          try {
1344              p.setMaximumPoolSize(1);
# Line 1339 | Line 1355 | public class ThreadPoolExecutorSubclassT
1355       * if given a negative value
1356       */
1357      public void testMaximumPoolSizeIllegalArgumentException2() {
1358 <        ThreadPoolExecutor p =
1358 >        final ThreadPoolExecutor p =
1359              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1360          try {
1361              p.setMaximumPoolSize(-1);
# Line 1356 | Line 1372 | public class ThreadPoolExecutorSubclassT
1372       * when given a negative value
1373       */
1374      public void testKeepAliveTimeIllegalArgumentException() {
1375 <        ThreadPoolExecutor p =
1375 >        final ThreadPoolExecutor p =
1376              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1377  
1378          try {
# Line 1404 | Line 1420 | public class ThreadPoolExecutorSubclassT
1420       * completed submit of callable returns result
1421       */
1422      public void testSubmitCallable() throws Exception {
1423 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1423 >        final ExecutorService e =
1424 >            new CustomTPE(2, 2,
1425 >                          LONG_DELAY_MS, MILLISECONDS,
1426 >                          new ArrayBlockingQueue<Runnable>(10));
1427          try {
1428              Future<String> future = e.submit(new StringTask());
1429              String result = future.get();
# Line 1418 | Line 1437 | public class ThreadPoolExecutorSubclassT
1437       * completed submit of runnable returns successfully
1438       */
1439      public void testSubmitRunnable() throws Exception {
1440 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1440 >        final ExecutorService e =
1441 >            new CustomTPE(2, 2,
1442 >                          LONG_DELAY_MS, MILLISECONDS,
1443 >                          new ArrayBlockingQueue<Runnable>(10));
1444          try {
1445              Future<?> future = e.submit(new NoOpRunnable());
1446              future.get();
# Line 1432 | Line 1454 | public class ThreadPoolExecutorSubclassT
1454       * completed submit of (runnable, result) returns result
1455       */
1456      public void testSubmitRunnable2() throws Exception {
1457 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1457 >        final ExecutorService e =
1458 >            new CustomTPE(2, 2,
1459 >                          LONG_DELAY_MS, MILLISECONDS,
1460 >                          new ArrayBlockingQueue<Runnable>(10));
1461          try {
1462              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
1463              String result = future.get();
# Line 1446 | Line 1471 | public class ThreadPoolExecutorSubclassT
1471       * invokeAny(null) throws NPE
1472       */
1473      public void testInvokeAny1() throws Exception {
1474 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1474 >        final ExecutorService e =
1475 >            new CustomTPE(2, 2,
1476 >                          LONG_DELAY_MS, MILLISECONDS,
1477 >                          new ArrayBlockingQueue<Runnable>(10));
1478          try {
1479              e.invokeAny(null);
1480              shouldThrow();
# Line 1460 | Line 1488 | public class ThreadPoolExecutorSubclassT
1488       * invokeAny(empty collection) throws IAE
1489       */
1490      public void testInvokeAny2() throws Exception {
1491 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1491 >        final ExecutorService e =
1492 >            new CustomTPE(2, 2,
1493 >                          LONG_DELAY_MS, MILLISECONDS,
1494 >                          new ArrayBlockingQueue<Runnable>(10));
1495          try {
1496              e.invokeAny(new ArrayList<Callable<String>>());
1497              shouldThrow();
# Line 1475 | Line 1506 | public class ThreadPoolExecutorSubclassT
1506       */
1507      public void testInvokeAny3() throws Exception {
1508          CountDownLatch latch = new CountDownLatch(1);
1509 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1509 >        final ExecutorService e =
1510 >            new CustomTPE(2, 2,
1511 >                          LONG_DELAY_MS, MILLISECONDS,
1512 >                          new ArrayBlockingQueue<Runnable>(10));
1513          List<Callable<String>> l = new ArrayList<Callable<String>>();
1514          l.add(latchAwaitingStringTask(latch));
1515          l.add(null);
# Line 1493 | Line 1527 | public class ThreadPoolExecutorSubclassT
1527       * invokeAny(c) throws ExecutionException if no task completes
1528       */
1529      public void testInvokeAny4() throws Exception {
1530 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1530 >        final ExecutorService e =
1531 >            new CustomTPE(2, 2,
1532 >                          LONG_DELAY_MS, MILLISECONDS,
1533 >                          new ArrayBlockingQueue<Runnable>(10));
1534          List<Callable<String>> l = new ArrayList<Callable<String>>();
1535          l.add(new NPETask());
1536          try {
# Line 1510 | Line 1547 | public class ThreadPoolExecutorSubclassT
1547       * invokeAny(c) returns result of some task
1548       */
1549      public void testInvokeAny5() throws Exception {
1550 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1550 >        final ExecutorService e =
1551 >            new CustomTPE(2, 2,
1552 >                          LONG_DELAY_MS, MILLISECONDS,
1553 >                          new ArrayBlockingQueue<Runnable>(10));
1554          try {
1555              List<Callable<String>> l = new ArrayList<Callable<String>>();
1556              l.add(new StringTask());
# Line 1526 | Line 1566 | public class ThreadPoolExecutorSubclassT
1566       * invokeAll(null) throws NPE
1567       */
1568      public void testInvokeAll1() throws Exception {
1569 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1569 >        final ExecutorService e =
1570 >            new CustomTPE(2, 2,
1571 >                          LONG_DELAY_MS, MILLISECONDS,
1572 >                          new ArrayBlockingQueue<Runnable>(10));
1573          try {
1574              e.invokeAll(null);
1575              shouldThrow();
# Line 1540 | Line 1583 | public class ThreadPoolExecutorSubclassT
1583       * invokeAll(empty collection) returns empty collection
1584       */
1585      public void testInvokeAll2() throws Exception {
1586 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1586 >        final ExecutorService e =
1587 >            new CustomTPE(2, 2,
1588 >                          LONG_DELAY_MS, MILLISECONDS,
1589 >                          new ArrayBlockingQueue<Runnable>(10));
1590          try {
1591              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1592              assertTrue(r.isEmpty());
# Line 1553 | Line 1599 | public class ThreadPoolExecutorSubclassT
1599       * invokeAll(c) throws NPE if c has null elements
1600       */
1601      public void testInvokeAll3() throws Exception {
1602 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1602 >        final ExecutorService e =
1603 >            new CustomTPE(2, 2,
1604 >                          LONG_DELAY_MS, MILLISECONDS,
1605 >                          new ArrayBlockingQueue<Runnable>(10));
1606          List<Callable<String>> l = new ArrayList<Callable<String>>();
1607          l.add(new StringTask());
1608          l.add(null);
# Line 1570 | Line 1619 | public class ThreadPoolExecutorSubclassT
1619       * get of element of invokeAll(c) throws exception on failed task
1620       */
1621      public void testInvokeAll4() throws Exception {
1622 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1622 >        final ExecutorService e =
1623 >            new CustomTPE(2, 2,
1624 >                          LONG_DELAY_MS, MILLISECONDS,
1625 >                          new ArrayBlockingQueue<Runnable>(10));
1626          List<Callable<String>> l = new ArrayList<Callable<String>>();
1627          l.add(new NPETask());
1628          List<Future<String>> futures = e.invokeAll(l);
# Line 1589 | Line 1641 | public class ThreadPoolExecutorSubclassT
1641       * invokeAll(c) returns results of all completed tasks
1642       */
1643      public void testInvokeAll5() throws Exception {
1644 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1644 >        final ExecutorService e =
1645 >            new CustomTPE(2, 2,
1646 >                          LONG_DELAY_MS, MILLISECONDS,
1647 >                          new ArrayBlockingQueue<Runnable>(10));
1648          try {
1649              List<Callable<String>> l = new ArrayList<Callable<String>>();
1650              l.add(new StringTask());
# Line 1607 | Line 1662 | public class ThreadPoolExecutorSubclassT
1662       * timed invokeAny(null) throws NPE
1663       */
1664      public void testTimedInvokeAny1() throws Exception {
1665 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1665 >        final ExecutorService e =
1666 >            new CustomTPE(2, 2,
1667 >                          LONG_DELAY_MS, MILLISECONDS,
1668 >                          new ArrayBlockingQueue<Runnable>(10));
1669          try {
1670              e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1671              shouldThrow();
# Line 1621 | Line 1679 | public class ThreadPoolExecutorSubclassT
1679       * timed invokeAny(,,null) throws NPE
1680       */
1681      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
1682 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1682 >        final ExecutorService e =
1683 >            new CustomTPE(2, 2,
1684 >                          LONG_DELAY_MS, MILLISECONDS,
1685 >                          new ArrayBlockingQueue<Runnable>(10));
1686          List<Callable<String>> l = new ArrayList<Callable<String>>();
1687          l.add(new StringTask());
1688          try {
# Line 1637 | Line 1698 | public class ThreadPoolExecutorSubclassT
1698       * timed invokeAny(empty collection) throws IAE
1699       */
1700      public void testTimedInvokeAny2() throws Exception {
1701 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1701 >        final ExecutorService e =
1702 >            new CustomTPE(2, 2,
1703 >                          LONG_DELAY_MS, MILLISECONDS,
1704 >                          new ArrayBlockingQueue<Runnable>(10));
1705          try {
1706              e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1707              shouldThrow();
# Line 1652 | Line 1716 | public class ThreadPoolExecutorSubclassT
1716       */
1717      public void testTimedInvokeAny3() throws Exception {
1718          CountDownLatch latch = new CountDownLatch(1);
1719 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1719 >        final ExecutorService e =
1720 >            new CustomTPE(2, 2,
1721 >                          LONG_DELAY_MS, MILLISECONDS,
1722 >                          new ArrayBlockingQueue<Runnable>(10));
1723          List<Callable<String>> l = new ArrayList<Callable<String>>();
1724          l.add(latchAwaitingStringTask(latch));
1725          l.add(null);
# Line 1670 | Line 1737 | public class ThreadPoolExecutorSubclassT
1737       * timed invokeAny(c) throws ExecutionException if no task completes
1738       */
1739      public void testTimedInvokeAny4() throws Exception {
1740 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1740 >        final ExecutorService e =
1741 >            new CustomTPE(2, 2,
1742 >                          LONG_DELAY_MS, MILLISECONDS,
1743 >                          new ArrayBlockingQueue<Runnable>(10));
1744          List<Callable<String>> l = new ArrayList<Callable<String>>();
1745          l.add(new NPETask());
1746          try {
# Line 1687 | Line 1757 | public class ThreadPoolExecutorSubclassT
1757       * timed invokeAny(c) returns result of some task
1758       */
1759      public void testTimedInvokeAny5() throws Exception {
1760 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1760 >        final ExecutorService e =
1761 >            new CustomTPE(2, 2,
1762 >                          LONG_DELAY_MS, MILLISECONDS,
1763 >                          new ArrayBlockingQueue<Runnable>(10));
1764          try {
1765              List<Callable<String>> l = new ArrayList<Callable<String>>();
1766              l.add(new StringTask());
# Line 1703 | Line 1776 | public class ThreadPoolExecutorSubclassT
1776       * timed invokeAll(null) throws NPE
1777       */
1778      public void testTimedInvokeAll1() throws Exception {
1779 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1779 >        final ExecutorService e =
1780 >            new CustomTPE(2, 2,
1781 >                          LONG_DELAY_MS, MILLISECONDS,
1782 >                          new ArrayBlockingQueue<Runnable>(10));
1783          try {
1784              e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1785              shouldThrow();
# Line 1717 | Line 1793 | public class ThreadPoolExecutorSubclassT
1793       * timed invokeAll(,,null) throws NPE
1794       */
1795      public void testTimedInvokeAllNullTimeUnit() throws Exception {
1796 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1796 >        final ExecutorService e =
1797 >            new CustomTPE(2, 2,
1798 >                          LONG_DELAY_MS, MILLISECONDS,
1799 >                          new ArrayBlockingQueue<Runnable>(10));
1800          List<Callable<String>> l = new ArrayList<Callable<String>>();
1801          l.add(new StringTask());
1802          try {
# Line 1733 | Line 1812 | public class ThreadPoolExecutorSubclassT
1812       * timed invokeAll(empty collection) returns empty collection
1813       */
1814      public void testTimedInvokeAll2() throws Exception {
1815 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1815 >        final ExecutorService e =
1816 >            new CustomTPE(2, 2,
1817 >                          LONG_DELAY_MS, MILLISECONDS,
1818 >                          new ArrayBlockingQueue<Runnable>(10));
1819          try {
1820              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1821              assertTrue(r.isEmpty());
# Line 1746 | Line 1828 | public class ThreadPoolExecutorSubclassT
1828       * timed invokeAll(c) throws NPE if c has null elements
1829       */
1830      public void testTimedInvokeAll3() throws Exception {
1831 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1831 >        final ExecutorService e =
1832 >            new CustomTPE(2, 2,
1833 >                          LONG_DELAY_MS, MILLISECONDS,
1834 >                          new ArrayBlockingQueue<Runnable>(10));
1835          List<Callable<String>> l = new ArrayList<Callable<String>>();
1836          l.add(new StringTask());
1837          l.add(null);
# Line 1763 | Line 1848 | public class ThreadPoolExecutorSubclassT
1848       * get of element of invokeAll(c) throws exception on failed task
1849       */
1850      public void testTimedInvokeAll4() throws Exception {
1851 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1851 >        final ExecutorService e =
1852 >            new CustomTPE(2, 2,
1853 >                          LONG_DELAY_MS, MILLISECONDS,
1854 >                          new ArrayBlockingQueue<Runnable>(10));
1855          List<Callable<String>> l = new ArrayList<Callable<String>>();
1856          l.add(new NPETask());
1857          List<Future<String>> futures =
# Line 1783 | Line 1871 | public class ThreadPoolExecutorSubclassT
1871       * timed invokeAll(c) returns results of all completed tasks
1872       */
1873      public void testTimedInvokeAll5() throws Exception {
1874 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1874 >        final ExecutorService e =
1875 >            new CustomTPE(2, 2,
1876 >                          LONG_DELAY_MS, MILLISECONDS,
1877 >                          new ArrayBlockingQueue<Runnable>(10));
1878          try {
1879              List<Callable<String>> l = new ArrayList<Callable<String>>();
1880              l.add(new StringTask());
# Line 1802 | Line 1893 | public class ThreadPoolExecutorSubclassT
1893       * timed invokeAll(c) cancels tasks not completed by timeout
1894       */
1895      public void testTimedInvokeAll6() throws Exception {
1896 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1896 >        final ExecutorService e =
1897 >            new CustomTPE(2, 2,
1898 >                          LONG_DELAY_MS, MILLISECONDS,
1899 >                          new ArrayBlockingQueue<Runnable>(10));
1900          try {
1901              for (long timeout = timeoutMillis();;) {
1902                  List<Callable<String>> tasks = new ArrayList<>();
# Line 1860 | Line 1954 | public class ThreadPoolExecutorSubclassT
1954       * allowsCoreThreadTimeOut is by default false.
1955       */
1956      public void testAllowsCoreThreadTimeOut() {
1957 <        ThreadPoolExecutor p = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1957 >        final ThreadPoolExecutor p =
1958 >            new CustomTPE(2, 2,
1959 >                          1000, MILLISECONDS,
1960 >                          new ArrayBlockingQueue<Runnable>(10));
1961          assertFalse(p.allowsCoreThreadTimeOut());
1962          joinPool(p);
1963      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines