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.81 by jsr166, Sun Oct 4 06:45:29 2015 UTC vs.
Revision 1.82 by jsr166, Sun Oct 4 07:23:20 2015 UTC

# Line 1343 | Line 1343 | public class ThreadPoolExecutorSubclassT
1343              new CustomTPE(2, 3,
1344                            LONG_DELAY_MS, MILLISECONDS,
1345                            new ArrayBlockingQueue<Runnable>(10));
1346 <        try {
1347 <            p.setMaximumPoolSize(1);
1348 <            shouldThrow();
1349 <        } catch (IllegalArgumentException success) {
1350 <        } finally {
1351 <            try { p.shutdown(); } catch (SecurityException ok) { return; }
1346 >        try (PoolCleaner cleaner = cleaner(p)) {
1347 >            try {
1348 >                p.setMaximumPoolSize(1);
1349 >                shouldThrow();
1350 >            } catch (IllegalArgumentException success) {}
1351          }
1353        joinPool(p);
1352      }
1353  
1354      /**
# Line 1362 | Line 1360 | public class ThreadPoolExecutorSubclassT
1360              new CustomTPE(2, 3,
1361                            LONG_DELAY_MS,
1362                            MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1363 <        try {
1364 <            p.setMaximumPoolSize(-1);
1365 <            shouldThrow();
1366 <        } catch (IllegalArgumentException success) {
1367 <        } finally {
1370 <            try { p.shutdown(); } catch (SecurityException ok) { return; }
1363 >        try (PoolCleaner cleaner = cleaner(p)) {
1364 >            try {
1365 >                p.setMaximumPoolSize(-1);
1366 >                shouldThrow();
1367 >            } catch (IllegalArgumentException success) {}
1368          }
1372        joinPool(p);
1369      }
1370  
1371      /**
# Line 1381 | Line 1377 | public class ThreadPoolExecutorSubclassT
1377              new CustomTPE(2, 3,
1378                            LONG_DELAY_MS, MILLISECONDS,
1379                            new ArrayBlockingQueue<Runnable>(10));
1380 <
1381 <        try {
1382 <            p.setKeepAliveTime(-1,MILLISECONDS);
1383 <            shouldThrow();
1384 <        } catch (IllegalArgumentException success) {
1389 <        } finally {
1390 <            try { p.shutdown(); } catch (SecurityException ok) { return; }
1380 >        try (PoolCleaner cleaner = cleaner(p)) {
1381 >            try {
1382 >                p.setKeepAliveTime(-1, MILLISECONDS);
1383 >                shouldThrow();
1384 >            } catch (IllegalArgumentException success) {}
1385          }
1392        joinPool(p);
1386      }
1387  
1388      /**
# Line 1397 | Line 1390 | public class ThreadPoolExecutorSubclassT
1390       */
1391      public void testTerminated() {
1392          CustomTPE p = new CustomTPE();
1393 <        try { p.shutdown(); } catch (SecurityException ok) { return; }
1394 <        assertTrue(p.terminatedCalled());
1395 <        joinPool(p);
1393 >        try (PoolCleaner cleaner = cleaner(p)) {
1394 >            try { p.shutdown(); } catch (SecurityException ok) { return; }
1395 >            assertTrue(p.terminatedCalled());
1396 >            assertTrue(p.isShutdown());
1397 >        }
1398      }
1399  
1400      /**
# Line 1407 | Line 1402 | public class ThreadPoolExecutorSubclassT
1402       */
1403      public void testBeforeAfter() throws InterruptedException {
1404          CustomTPE p = new CustomTPE();
1405 <        try {
1405 >        try (PoolCleaner cleaner = cleaner(p)) {
1406              final CountDownLatch done = new CountDownLatch(1);
1407              p.execute(new CheckedRunnable() {
1408                  public void realRun() {
# Line 1417 | Line 1412 | public class ThreadPoolExecutorSubclassT
1412              assertEquals(0, done.getCount());
1413              assertTrue(p.afterCalled());
1414              assertTrue(p.beforeCalled());
1420            try { p.shutdown(); } catch (SecurityException ok) { return; }
1421        } finally {
1422            joinPool(p);
1415          }
1416      }
1417  
# Line 1431 | Line 1423 | public class ThreadPoolExecutorSubclassT
1423              new CustomTPE(2, 2,
1424                            LONG_DELAY_MS, MILLISECONDS,
1425                            new ArrayBlockingQueue<Runnable>(10));
1426 <        try {
1426 >        try (PoolCleaner cleaner = cleaner(e)) {
1427              Future<String> future = e.submit(new StringTask());
1428              String result = future.get();
1429              assertSame(TEST_STRING, result);
1438        } finally {
1439            joinPool(e);
1430          }
1431      }
1432  
# Line 1448 | Line 1438 | public class ThreadPoolExecutorSubclassT
1438              new CustomTPE(2, 2,
1439                            LONG_DELAY_MS, MILLISECONDS,
1440                            new ArrayBlockingQueue<Runnable>(10));
1441 <        try {
1441 >        try (PoolCleaner cleaner = cleaner(e)) {
1442              Future<?> future = e.submit(new NoOpRunnable());
1443              future.get();
1444              assertTrue(future.isDone());
1455        } finally {
1456            joinPool(e);
1445          }
1446      }
1447  
# Line 1465 | Line 1453 | public class ThreadPoolExecutorSubclassT
1453              new CustomTPE(2, 2,
1454                            LONG_DELAY_MS, MILLISECONDS,
1455                            new ArrayBlockingQueue<Runnable>(10));
1456 <        try {
1456 >        try (PoolCleaner cleaner = cleaner(e)) {
1457              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
1458              String result = future.get();
1459              assertSame(TEST_STRING, result);
1472        } finally {
1473            joinPool(e);
1460          }
1461      }
1462  
# Line 1482 | Line 1468 | public class ThreadPoolExecutorSubclassT
1468              new CustomTPE(2, 2,
1469                            LONG_DELAY_MS, MILLISECONDS,
1470                            new ArrayBlockingQueue<Runnable>(10));
1471 <        try {
1472 <            e.invokeAny(null);
1473 <            shouldThrow();
1474 <        } catch (NullPointerException success) {
1475 <        } finally {
1490 <            joinPool(e);
1471 >        try (PoolCleaner cleaner = cleaner(e)) {
1472 >            try {
1473 >                e.invokeAny(null);
1474 >                shouldThrow();
1475 >            } catch (NullPointerException success) {}
1476          }
1477      }
1478  
# Line 1499 | Line 1484 | public class ThreadPoolExecutorSubclassT
1484              new CustomTPE(2, 2,
1485                            LONG_DELAY_MS, MILLISECONDS,
1486                            new ArrayBlockingQueue<Runnable>(10));
1487 <        try {
1488 <            e.invokeAny(new ArrayList<Callable<String>>());
1489 <            shouldThrow();
1490 <        } catch (IllegalArgumentException success) {
1491 <        } finally {
1507 <            joinPool(e);
1487 >        try (PoolCleaner cleaner = cleaner(e)) {
1488 >            try {
1489 >                e.invokeAny(new ArrayList<Callable<String>>());
1490 >                shouldThrow();
1491 >            } catch (IllegalArgumentException success) {}
1492          }
1493      }
1494  
# Line 1517 | Line 1501 | public class ThreadPoolExecutorSubclassT
1501              new CustomTPE(2, 2,
1502                            LONG_DELAY_MS, MILLISECONDS,
1503                            new ArrayBlockingQueue<Runnable>(10));
1504 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1505 <        l.add(latchAwaitingStringTask(latch));
1506 <        l.add(null);
1507 <        try {
1508 <            e.invokeAny(l);
1509 <            shouldThrow();
1510 <        } catch (NullPointerException success) {
1511 <        } finally {
1504 >        try (PoolCleaner cleaner = cleaner(e)) {
1505 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1506 >            l.add(latchAwaitingStringTask(latch));
1507 >            l.add(null);
1508 >            try {
1509 >                e.invokeAny(l);
1510 >                shouldThrow();
1511 >            } catch (NullPointerException success) {}
1512              latch.countDown();
1529            joinPool(e);
1513          }
1514      }
1515  
# Line 1538 | Line 1521 | public class ThreadPoolExecutorSubclassT
1521              new CustomTPE(2, 2,
1522                            LONG_DELAY_MS, MILLISECONDS,
1523                            new ArrayBlockingQueue<Runnable>(10));
1524 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1525 <        l.add(new NPETask());
1526 <        try {
1527 <            e.invokeAny(l);
1528 <            shouldThrow();
1529 <        } catch (ExecutionException success) {
1530 <            assertTrue(success.getCause() instanceof NullPointerException);
1531 <        } finally {
1532 <            joinPool(e);
1524 >        try (PoolCleaner cleaner = cleaner(e)) {
1525 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1526 >            l.add(new NPETask());
1527 >            try {
1528 >                e.invokeAny(l);
1529 >                shouldThrow();
1530 >            } catch (ExecutionException success) {
1531 >                assertTrue(success.getCause() instanceof NullPointerException);
1532 >            }
1533          }
1534      }
1535  
# Line 1558 | Line 1541 | public class ThreadPoolExecutorSubclassT
1541              new CustomTPE(2, 2,
1542                            LONG_DELAY_MS, MILLISECONDS,
1543                            new ArrayBlockingQueue<Runnable>(10));
1544 <        try {
1544 >        try (PoolCleaner cleaner = cleaner(e)) {
1545              List<Callable<String>> l = new ArrayList<Callable<String>>();
1546              l.add(new StringTask());
1547              l.add(new StringTask());
1548              String result = e.invokeAny(l);
1549              assertSame(TEST_STRING, result);
1567        } finally {
1568            joinPool(e);
1550          }
1551      }
1552  
# Line 1577 | Line 1558 | public class ThreadPoolExecutorSubclassT
1558              new CustomTPE(2, 2,
1559                            LONG_DELAY_MS, MILLISECONDS,
1560                            new ArrayBlockingQueue<Runnable>(10));
1561 <        try {
1562 <            e.invokeAll(null);
1563 <            shouldThrow();
1564 <        } catch (NullPointerException success) {
1565 <        } finally {
1585 <            joinPool(e);
1561 >        try (PoolCleaner cleaner = cleaner(e)) {
1562 >            try {
1563 >                e.invokeAll(null);
1564 >                shouldThrow();
1565 >            } catch (NullPointerException success) {}
1566          }
1567      }
1568  
# Line 1594 | Line 1574 | public class ThreadPoolExecutorSubclassT
1574              new CustomTPE(2, 2,
1575                            LONG_DELAY_MS, MILLISECONDS,
1576                            new ArrayBlockingQueue<Runnable>(10));
1577 <        try {
1577 >        try (PoolCleaner cleaner = cleaner(e)) {
1578              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1579              assertTrue(r.isEmpty());
1600        } finally {
1601            joinPool(e);
1580          }
1581      }
1582  
# Line 1610 | Line 1588 | public class ThreadPoolExecutorSubclassT
1588              new CustomTPE(2, 2,
1589                            LONG_DELAY_MS, MILLISECONDS,
1590                            new ArrayBlockingQueue<Runnable>(10));
1591 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1592 <        l.add(new StringTask());
1593 <        l.add(null);
1594 <        try {
1595 <            e.invokeAll(l);
1596 <            shouldThrow();
1597 <        } catch (NullPointerException success) {
1598 <        } finally {
1621 <            joinPool(e);
1591 >        try (PoolCleaner cleaner = cleaner(e)) {
1592 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1593 >            l.add(new StringTask());
1594 >            l.add(null);
1595 >            try {
1596 >                e.invokeAll(l);
1597 >                shouldThrow();
1598 >            } catch (NullPointerException success) {}
1599          }
1600      }
1601  
# Line 1630 | Line 1607 | public class ThreadPoolExecutorSubclassT
1607              new CustomTPE(2, 2,
1608                            LONG_DELAY_MS, MILLISECONDS,
1609                            new ArrayBlockingQueue<Runnable>(10));
1610 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1611 <        l.add(new NPETask());
1612 <        List<Future<String>> futures = e.invokeAll(l);
1613 <        assertEquals(1, futures.size());
1614 <        try {
1615 <            futures.get(0).get();
1616 <            shouldThrow();
1617 <        } catch (ExecutionException success) {
1618 <            assertTrue(success.getCause() instanceof NullPointerException);
1619 <        } finally {
1620 <            joinPool(e);
1610 >        try (PoolCleaner cleaner = cleaner(e)) {
1611 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1612 >            l.add(new NPETask());
1613 >            List<Future<String>> futures = e.invokeAll(l);
1614 >            assertEquals(1, futures.size());
1615 >            try {
1616 >                futures.get(0).get();
1617 >                shouldThrow();
1618 >            } catch (ExecutionException success) {
1619 >                assertTrue(success.getCause() instanceof NullPointerException);
1620 >            }
1621          }
1622      }
1623  
# Line 1652 | Line 1629 | public class ThreadPoolExecutorSubclassT
1629              new CustomTPE(2, 2,
1630                            LONG_DELAY_MS, MILLISECONDS,
1631                            new ArrayBlockingQueue<Runnable>(10));
1632 <        try {
1632 >        try (PoolCleaner cleaner = cleaner(e)) {
1633              List<Callable<String>> l = new ArrayList<Callable<String>>();
1634              l.add(new StringTask());
1635              l.add(new StringTask());
# Line 1660 | Line 1637 | public class ThreadPoolExecutorSubclassT
1637              assertEquals(2, futures.size());
1638              for (Future<String> future : futures)
1639                  assertSame(TEST_STRING, future.get());
1663        } finally {
1664            joinPool(e);
1640          }
1641      }
1642  
# Line 1673 | Line 1648 | public class ThreadPoolExecutorSubclassT
1648              new CustomTPE(2, 2,
1649                            LONG_DELAY_MS, MILLISECONDS,
1650                            new ArrayBlockingQueue<Runnable>(10));
1651 <        try {
1652 <            e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1653 <            shouldThrow();
1654 <        } catch (NullPointerException success) {
1655 <        } finally {
1681 <            joinPool(e);
1651 >        try (PoolCleaner cleaner = cleaner(e)) {
1652 >            try {
1653 >                e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1654 >                shouldThrow();
1655 >            } catch (NullPointerException success) {}
1656          }
1657      }
1658  
# Line 1690 | Line 1664 | public class ThreadPoolExecutorSubclassT
1664              new CustomTPE(2, 2,
1665                            LONG_DELAY_MS, MILLISECONDS,
1666                            new ArrayBlockingQueue<Runnable>(10));
1667 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1668 <        l.add(new StringTask());
1669 <        try {
1670 <            e.invokeAny(l, MEDIUM_DELAY_MS, null);
1671 <            shouldThrow();
1672 <        } catch (NullPointerException success) {
1673 <        } finally {
1700 <            joinPool(e);
1667 >        try (PoolCleaner cleaner = cleaner(e)) {
1668 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1669 >            l.add(new StringTask());
1670 >            try {
1671 >                e.invokeAny(l, MEDIUM_DELAY_MS, null);
1672 >                shouldThrow();
1673 >            } catch (NullPointerException success) {}
1674          }
1675      }
1676  
# Line 1709 | Line 1682 | public class ThreadPoolExecutorSubclassT
1682              new CustomTPE(2, 2,
1683                            LONG_DELAY_MS, MILLISECONDS,
1684                            new ArrayBlockingQueue<Runnable>(10));
1685 <        try {
1686 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1687 <            shouldThrow();
1688 <        } catch (IllegalArgumentException success) {
1689 <        } finally {
1690 <            joinPool(e);
1685 >        try (PoolCleaner cleaner = cleaner(e)) {
1686 >            try {
1687 >                e.invokeAny(new ArrayList<Callable<String>>(),
1688 >                            MEDIUM_DELAY_MS, MILLISECONDS);
1689 >                shouldThrow();
1690 >            } catch (IllegalArgumentException success) {}
1691          }
1692      }
1693  
# Line 1727 | Line 1700 | public class ThreadPoolExecutorSubclassT
1700              new CustomTPE(2, 2,
1701                            LONG_DELAY_MS, MILLISECONDS,
1702                            new ArrayBlockingQueue<Runnable>(10));
1703 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1704 <        l.add(latchAwaitingStringTask(latch));
1705 <        l.add(null);
1706 <        try {
1707 <            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1708 <            shouldThrow();
1709 <        } catch (NullPointerException success) {
1710 <        } finally {
1703 >        try (PoolCleaner cleaner = cleaner(e)) {
1704 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1705 >            l.add(latchAwaitingStringTask(latch));
1706 >            l.add(null);
1707 >            try {
1708 >                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1709 >                shouldThrow();
1710 >            } catch (NullPointerException success) {}
1711              latch.countDown();
1739            joinPool(e);
1712          }
1713      }
1714  
# Line 1748 | Line 1720 | public class ThreadPoolExecutorSubclassT
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(new NPETask());
1725 <        try {
1726 <            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1727 <            shouldThrow();
1728 <        } catch (ExecutionException success) {
1729 <            assertTrue(success.getCause() instanceof NullPointerException);
1730 <        } finally {
1731 <            joinPool(e);
1723 >        try (PoolCleaner cleaner = cleaner(e)) {
1724 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1725 >            l.add(new NPETask());
1726 >            try {
1727 >                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1728 >                shouldThrow();
1729 >            } catch (ExecutionException success) {
1730 >                assertTrue(success.getCause() instanceof NullPointerException);
1731 >            }
1732          }
1733      }
1734  
# Line 1768 | Line 1740 | public class ThreadPoolExecutorSubclassT
1740              new CustomTPE(2, 2,
1741                            LONG_DELAY_MS, MILLISECONDS,
1742                            new ArrayBlockingQueue<Runnable>(10));
1743 <        try {
1743 >        try (PoolCleaner cleaner = cleaner(e)) {
1744              List<Callable<String>> l = new ArrayList<Callable<String>>();
1745              l.add(new StringTask());
1746              l.add(new StringTask());
1747              String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1748              assertSame(TEST_STRING, result);
1777        } finally {
1778            joinPool(e);
1749          }
1750      }
1751  
# Line 1787 | Line 1757 | public class ThreadPoolExecutorSubclassT
1757              new CustomTPE(2, 2,
1758                            LONG_DELAY_MS, MILLISECONDS,
1759                            new ArrayBlockingQueue<Runnable>(10));
1760 <        try {
1761 <            e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1762 <            shouldThrow();
1763 <        } catch (NullPointerException success) {
1764 <        } finally {
1795 <            joinPool(e);
1760 >        try (PoolCleaner cleaner = cleaner(e)) {
1761 >            try {
1762 >                e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1763 >                shouldThrow();
1764 >            } catch (NullPointerException success) {}
1765          }
1766      }
1767  
# Line 1804 | Line 1773 | public class ThreadPoolExecutorSubclassT
1773              new CustomTPE(2, 2,
1774                            LONG_DELAY_MS, MILLISECONDS,
1775                            new ArrayBlockingQueue<Runnable>(10));
1776 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1777 <        l.add(new StringTask());
1778 <        try {
1779 <            e.invokeAll(l, MEDIUM_DELAY_MS, null);
1780 <            shouldThrow();
1781 <        } catch (NullPointerException success) {
1782 <        } finally {
1814 <            joinPool(e);
1776 >        try (PoolCleaner cleaner = cleaner(e)) {
1777 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1778 >            l.add(new StringTask());
1779 >            try {
1780 >                e.invokeAll(l, MEDIUM_DELAY_MS, null);
1781 >                shouldThrow();
1782 >            } catch (NullPointerException success) {}
1783          }
1784      }
1785  
# Line 1823 | Line 1791 | public class ThreadPoolExecutorSubclassT
1791              new CustomTPE(2, 2,
1792                            LONG_DELAY_MS, MILLISECONDS,
1793                            new ArrayBlockingQueue<Runnable>(10));
1794 <        try {
1795 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1794 >        try (PoolCleaner cleaner = cleaner(e)) {
1795 >            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(),
1796 >                                                 MEDIUM_DELAY_MS, MILLISECONDS);
1797              assertTrue(r.isEmpty());
1829        } finally {
1830            joinPool(e);
1798          }
1799      }
1800  
# Line 1839 | Line 1806 | public class ThreadPoolExecutorSubclassT
1806              new CustomTPE(2, 2,
1807                            LONG_DELAY_MS, MILLISECONDS,
1808                            new ArrayBlockingQueue<Runnable>(10));
1809 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1810 <        l.add(new StringTask());
1811 <        l.add(null);
1812 <        try {
1813 <            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1814 <            shouldThrow();
1815 <        } catch (NullPointerException success) {
1816 <        } finally {
1850 <            joinPool(e);
1809 >        try (PoolCleaner cleaner = cleaner(e)) {
1810 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1811 >            l.add(new StringTask());
1812 >            l.add(null);
1813 >            try {
1814 >                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1815 >                shouldThrow();
1816 >            } catch (NullPointerException success) {}
1817          }
1818      }
1819  
# Line 1859 | Line 1825 | public class ThreadPoolExecutorSubclassT
1825              new CustomTPE(2, 2,
1826                            LONG_DELAY_MS, MILLISECONDS,
1827                            new ArrayBlockingQueue<Runnable>(10));
1828 <        List<Callable<String>> l = new ArrayList<Callable<String>>();
1829 <        l.add(new NPETask());
1830 <        List<Future<String>> futures =
1831 <            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1832 <        assertEquals(1, futures.size());
1833 <        try {
1834 <            futures.get(0).get();
1835 <            shouldThrow();
1836 <        } catch (ExecutionException success) {
1837 <            assertTrue(success.getCause() instanceof NullPointerException);
1838 <        } finally {
1839 <            joinPool(e);
1828 >        try (PoolCleaner cleaner = cleaner(e)) {
1829 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1830 >            l.add(new NPETask());
1831 >            List<Future<String>> futures =
1832 >                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1833 >            assertEquals(1, futures.size());
1834 >            try {
1835 >                futures.get(0).get();
1836 >                shouldThrow();
1837 >            } catch (ExecutionException success) {
1838 >                assertTrue(success.getCause() instanceof NullPointerException);
1839 >            }
1840          }
1841      }
1842  
# Line 1882 | Line 1848 | public class ThreadPoolExecutorSubclassT
1848              new CustomTPE(2, 2,
1849                            LONG_DELAY_MS, MILLISECONDS,
1850                            new ArrayBlockingQueue<Runnable>(10));
1851 <        try {
1851 >        try (PoolCleaner cleaner = cleaner(e)) {
1852              List<Callable<String>> l = new ArrayList<Callable<String>>();
1853              l.add(new StringTask());
1854              l.add(new StringTask());
# Line 1891 | Line 1857 | public class ThreadPoolExecutorSubclassT
1857              assertEquals(2, futures.size());
1858              for (Future<String> future : futures)
1859                  assertSame(TEST_STRING, future.get());
1894        } finally {
1895            joinPool(e);
1860          }
1861      }
1862  
# Line 1904 | Line 1868 | public class ThreadPoolExecutorSubclassT
1868              new CustomTPE(2, 2,
1869                            LONG_DELAY_MS, MILLISECONDS,
1870                            new ArrayBlockingQueue<Runnable>(10));
1871 <        try {
1871 >        try (PoolCleaner cleaner = cleaner(e)) {
1872              for (long timeout = timeoutMillis();;) {
1873                  List<Callable<String>> tasks = new ArrayList<>();
1874                  tasks.add(new StringTask("0"));
# Line 1928 | Line 1892 | public class ThreadPoolExecutorSubclassT
1892                          fail("expected exactly one task to be cancelled");
1893                  }
1894              }
1931        } finally {
1932            joinPool(e);
1895          }
1896      }
1897  
# Line 1943 | Line 1905 | public class ThreadPoolExecutorSubclassT
1905                            LONG_DELAY_MS, MILLISECONDS,
1906                            new LinkedBlockingQueue<Runnable>(),
1907                            new FailingThreadFactory());
1908 <        try {
1908 >        try (PoolCleaner cleaner = cleaner(e)) {
1909              final int TASKS = 100;
1910              final CountDownLatch done = new CountDownLatch(TASKS);
1911              for (int k = 0; k < TASKS; ++k)
# Line 1952 | Line 1914 | public class ThreadPoolExecutorSubclassT
1914                          done.countDown();
1915                      }});
1916              assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
1955        } finally {
1956            joinPool(e);
1917          }
1918      }
1919  
# Line 1965 | Line 1925 | public class ThreadPoolExecutorSubclassT
1925              new CustomTPE(2, 2,
1926                            1000, MILLISECONDS,
1927                            new ArrayBlockingQueue<Runnable>(10));
1928 <        assertFalse(p.allowsCoreThreadTimeOut());
1929 <        joinPool(p);
1928 >        try (PoolCleaner cleaner = cleaner(p)) {
1929 >            assertFalse(p.allowsCoreThreadTimeOut());
1930 >        }
1931      }
1932  
1933      /**
# Line 1978 | Line 1939 | public class ThreadPoolExecutorSubclassT
1939              new CustomTPE(2, 10,
1940                            keepAliveTime, MILLISECONDS,
1941                            new ArrayBlockingQueue<Runnable>(10));
1942 <        final CountDownLatch threadStarted = new CountDownLatch(1);
1943 <        try {
1942 >        try (PoolCleaner cleaner = cleaner(p)) {
1943 >            final CountDownLatch threadStarted = new CountDownLatch(1);
1944              p.allowCoreThreadTimeOut(true);
1945              p.execute(new CheckedRunnable() {
1946                  public void realRun() {
# Line 1994 | Line 1955 | public class ThreadPoolExecutorSubclassT
1955                  Thread.yield();
1956              assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1957              assertEquals(0, p.getPoolSize());
1997        } finally {
1998            joinPool(p);
1958          }
1959      }
1960  
# Line 2008 | Line 1967 | public class ThreadPoolExecutorSubclassT
1967              new CustomTPE(2, 10,
1968                            keepAliveTime, MILLISECONDS,
1969                            new ArrayBlockingQueue<Runnable>(10));
1970 <        final CountDownLatch threadStarted = new CountDownLatch(1);
1971 <        try {
1970 >        try (PoolCleaner cleaner = cleaner(p)) {
1971 >            final CountDownLatch threadStarted = new CountDownLatch(1);
1972              p.allowCoreThreadTimeOut(false);
1973              p.execute(new CheckedRunnable() {
1974                  public void realRun() throws InterruptedException {
# Line 2018 | Line 1977 | public class ThreadPoolExecutorSubclassT
1977                  }});
1978              delay(2 * keepAliveTime);
1979              assertTrue(p.getPoolSize() >= 1);
2021        } finally {
2022            joinPool(p);
1980          }
1981      }
1982  
# Line 2032 | Line 1989 | public class ThreadPoolExecutorSubclassT
1989              new CustomTPE(1, 1,
1990                            LONG_DELAY_MS, MILLISECONDS,
1991                            new LinkedBlockingQueue<Runnable>());
1992 <        try {
1992 >        try (PoolCleaner cleaner = cleaner(e)) {
1993              final CountDownLatch blockerStarted = new CountDownLatch(1);
1994              final CountDownLatch done = new CountDownLatch(1);
1995              final List<Future<?>> futures = new ArrayList<>();
# Line 2059 | Line 2016 | public class ThreadPoolExecutorSubclassT
2016                  assertTrue(future.isDone());
2017              }
2018              done.countDown();
2062        } finally {
2063            joinPool(e);
2019          }
2020      }
2021  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines