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.92 by jsr166, Tue Oct 6 05:56:01 2015 UTC vs.
Revision 1.95 by jsr166, Thu Oct 8 03:08:37 2015 UTC

# Line 1725 | Line 1725 | public class ThreadPoolExecutorSubclassT
1725                            LONG_DELAY_MS, MILLISECONDS,
1726                            new ArrayBlockingQueue<Runnable>(10));
1727          try (PoolCleaner cleaner = cleaner(e)) {
1728 +            long startTime = System.nanoTime();
1729              List<Callable<String>> l = new ArrayList<Callable<String>>();
1730              l.add(new NPETask());
1731              try {
1732 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1732 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1733                  shouldThrow();
1734              } catch (ExecutionException success) {
1735                  assertTrue(success.getCause() instanceof NullPointerException);
1736              }
1737 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1738          }
1739      }
1740  
# Line 1745 | Line 1747 | public class ThreadPoolExecutorSubclassT
1747                            LONG_DELAY_MS, MILLISECONDS,
1748                            new ArrayBlockingQueue<Runnable>(10));
1749          try (PoolCleaner cleaner = cleaner(e)) {
1750 +            long startTime = System.nanoTime();
1751              List<Callable<String>> l = new ArrayList<Callable<String>>();
1752              l.add(new StringTask());
1753              l.add(new StringTask());
1754 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1754 >            String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1755              assertSame(TEST_STRING, result);
1756 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1757          }
1758      }
1759  
# Line 1868 | Line 1872 | public class ThreadPoolExecutorSubclassT
1872       * timed invokeAll(c) cancels tasks not completed by timeout
1873       */
1874      public void testTimedInvokeAll6() throws Exception {
1875 <        final ExecutorService e =
1876 <            new CustomTPE(2, 2,
1877 <                          LONG_DELAY_MS, MILLISECONDS,
1878 <                          new ArrayBlockingQueue<Runnable>(10));
1879 <        try (PoolCleaner cleaner = cleaner(e)) {
1880 <            for (long timeout = timeoutMillis();;) {
1875 >        for (long timeout = timeoutMillis();;) {
1876 >            final CountDownLatch done = new CountDownLatch(1);
1877 >            final Callable<String> waiter = new CheckedCallable<String>() {
1878 >                public String realCall() {
1879 >                    try { done.await(LONG_DELAY_MS, MILLISECONDS); }
1880 >                    catch (InterruptedException ok) {}
1881 >                    return "1"; }};
1882 >            final ExecutorService p =
1883 >                new CustomTPE(2, 2,
1884 >                              LONG_DELAY_MS, MILLISECONDS,
1885 >                              new ArrayBlockingQueue<Runnable>(10));
1886 >            try (PoolCleaner cleaner = cleaner(p, done)) {
1887                  List<Callable<String>> tasks = new ArrayList<>();
1888                  tasks.add(new StringTask("0"));
1889 <                tasks.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING));
1889 >                tasks.add(waiter);
1890                  tasks.add(new StringTask("2"));
1891                  long startTime = System.nanoTime();
1892                  List<Future<String>> futures =
1893 <                    e.invokeAll(tasks, timeout, MILLISECONDS);
1893 >                    p.invokeAll(tasks, timeout, MILLISECONDS);
1894                  assertEquals(tasks.size(), futures.size());
1895                  assertTrue(millisElapsedSince(startTime) >= timeout);
1896                  for (Future future : futures)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines