--- jsr166/src/test/tck/ScheduledExecutorTest.java 2015/10/08 03:03:36 1.75 +++ jsr166/src/test/tck/ScheduledExecutorTest.java 2015/10/25 02:58:25 1.78 @@ -164,7 +164,7 @@ public class ScheduledExecutorTest exten normalizedTime <= cycles) return; } - throw new AssertionError("unexpected execution rate"); + fail("unexpected execution rate"); } } @@ -190,7 +190,7 @@ public class ScheduledExecutorTest exten normalizedTime <= cycles) return; } - throw new AssertionError("unexpected execution rate"); + fail("unexpected execution rate"); } } @@ -1065,11 +1065,13 @@ public class ScheduledExecutorTest exten public void testTimedInvokeAny5() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); try (PoolCleaner cleaner = cleaner(e)) { + long startTime = System.nanoTime(); List> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); - String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); + String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); assertSame(TEST_STRING, result); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } } @@ -1204,4 +1206,27 @@ public class ScheduledExecutorTest exten } } + /** + * A fixed delay task with overflowing period should not prevent a + * one-shot task from executing. + * https://bugs.openjdk.java.net/browse/JDK-8051859 + */ + public void testScheduleWithFixedDelay_overflow() throws Exception { + final CountDownLatch delayedDone = new CountDownLatch(1); + final CountDownLatch immediateDone = new CountDownLatch(1); + final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); + try (PoolCleaner cleaner = cleaner(p)) { + final Runnable immediate = new Runnable() { public void run() { + immediateDone.countDown(); + }}; + final Runnable delayed = new Runnable() { public void run() { + delayedDone.countDown(); + p.submit(immediate); + }}; + p.scheduleWithFixedDelay(delayed, 0L, Long.MAX_VALUE, SECONDS); + await(delayedDone); + await(immediateDone); + } + } + }