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

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.38 by jsr166, Mon Sep 14 03:14:43 2015 UTC vs.
Revision 1.39 by jsr166, Sun Oct 4 06:05:53 2015 UTC

# Line 603 | Line 603 | public class AbstractExecutorServiceTest
603      public void testTimedInvokeAll6() throws Exception {
604          ExecutorService e = new DirectExecutorService();
605          try {
606 <            long timeout = timeoutMillis();
607 <            List<Callable<String>> tasks = new ArrayList<>();
608 <            tasks.add(new StringTask("0"));
609 <            tasks.add(Executors.callable(possiblyInterruptedRunnable(timeout),
610 <                                         TEST_STRING));
611 <            tasks.add(new StringTask("2"));
612 <            long startTime = System.nanoTime();
613 <            List<Future<String>> futures =
614 <                e.invokeAll(tasks, timeout, MILLISECONDS);
615 <            assertEquals(tasks.size(), futures.size());
616 <            assertTrue(millisElapsedSince(startTime) >= timeout);
617 <            for (Future future : futures)
618 <                assertTrue(future.isDone());
619 <            assertEquals("0", futures.get(0).get());
620 <            assertEquals(TEST_STRING, futures.get(1).get());
621 <            assertTrue(futures.get(2).isCancelled());
606 >            for (long timeout = timeoutMillis();;) {
607 >                List<Callable<String>> tasks = new ArrayList<>();
608 >                tasks.add(new StringTask("0"));
609 >                tasks.add(Executors.callable(possiblyInterruptedRunnable(timeout),
610 >                                             TEST_STRING));
611 >                tasks.add(new StringTask("2"));
612 >                long startTime = System.nanoTime();
613 >                List<Future<String>> futures =
614 >                    e.invokeAll(tasks, timeout, MILLISECONDS);
615 >                assertEquals(tasks.size(), futures.size());
616 >                assertTrue(millisElapsedSince(startTime) >= timeout);
617 >                for (Future future : futures)
618 >                    assertTrue(future.isDone());
619 >                try {
620 >                    assertEquals("0", futures.get(0).get());
621 >                    assertEquals(TEST_STRING, futures.get(1).get());
622 >                } catch (CancellationException retryWithLongerTimeout) {
623 >                    // unusual delay before starting second task
624 >                    timeout *= 2;
625 >                    if (timeout >= LONG_DELAY_MS / 2)
626 >                        fail("expected exactly one task to be cancelled");
627 >                    continue;
628 >                }
629 >                assertTrue(futures.get(2).isCancelled());
630 >                break;
631 >            }
632          } finally {
633              joinPool(e);
634          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines