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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.63 by jsr166, Sun Oct 4 08:27:41 2015 UTC vs.
Revision 1.65 by jsr166, Tue Oct 6 21:22:54 2015 UTC

# Line 256 | Line 256 | public class ForkJoinPoolTest extends JS
256       */
257      public void testSetUncaughtExceptionHandler() throws InterruptedException {
258          final CountDownLatch uehInvoked = new CountDownLatch(1);
259 <        final Thread.UncaughtExceptionHandler eh =
259 >        final Thread.UncaughtExceptionHandler ueh =
260              new Thread.UncaughtExceptionHandler() {
261                  public void uncaughtException(Thread t, Throwable e) {
262                      uehInvoked.countDown();
263                  }};
264          ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(),
265 <                                          eh, false);
266 <        try {
267 <            assertSame(eh, p.getUncaughtExceptionHandler());
265 >                                          ueh, false);
266 >        try (PoolCleaner cleaner = cleaner(p)) {
267 >            assertSame(ueh, p.getUncaughtExceptionHandler());
268              try {
269 <                p.execute(new FibTask(8));
270 <                assertTrue(uehInvoked.await(MEDIUM_DELAY_MS, MILLISECONDS));
271 <            } catch (RejectedExecutionException ok) {
269 >                try {
270 >                    p.execute(new FibTask(8));
271 >                    await(uehInvoked);
272 >                } catch (RejectedExecutionException ok) {}
273 >            } finally {
274 >                p.shutdownNow(); // failure might have prevented processing task
275              }
273        } finally {
274            p.shutdownNow(); // failure might have prevented processing task
275            joinPool(p);
276          }
277      }
278  
# Line 548 | Line 548 | public class ForkJoinPoolTest extends JS
548      public void testInterruptedSubmit() throws InterruptedException {
549          final CountDownLatch submitted    = new CountDownLatch(1);
550          final CountDownLatch quittingTime = new CountDownLatch(1);
551        final ExecutorService p = new ForkJoinPool(1);
551          final Callable<Void> awaiter = new CheckedCallable<Void>() {
552              public Void realCall() throws InterruptedException {
553 <                assertTrue(quittingTime.await(MEDIUM_DELAY_MS, MILLISECONDS));
553 >                assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS));
554                  return null;
555              }};
556 <        try {
556 >        final ExecutorService p = new ForkJoinPool(1);
557 >        try (PoolCleaner cleaner = cleaner(p, quittingTime)) {
558              Thread t = new Thread(new CheckedInterruptedRunnable() {
559                  public void realRun() throws Exception {
560                      Future<Void> future = p.submit(awaiter);
# Line 562 | Line 562 | public class ForkJoinPoolTest extends JS
562                      future.get();
563                  }});
564              t.start();
565 <            assertTrue(submitted.await(MEDIUM_DELAY_MS, MILLISECONDS));
565 >            await(submitted);
566              t.interrupt();
567 <            t.join();
568 <        } finally {
569 <            quittingTime.countDown();
570 <            joinPool(p);
567 >            awaitTermination(t);
568          }
569      }
570  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines