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.64 by jsr166, Mon Oct 5 22:54:45 2015 UTC vs.
Revision 1.66 by jsr166, Tue Oct 6 23:16:51 2015 UTC

# Line 64 | Line 64 | public class ForkJoinPoolTest extends JS
64          }
65      }
66  
67 +    static class MyError extends Error {}
68 +
69      // to test handlers
70      static class FailingFJWSubclass extends ForkJoinWorkerThread {
71          public FailingFJWSubclass(ForkJoinPool p) { super(p) ; }
72 <        protected void onStart() { super.onStart(); throw new Error(); }
72 >        protected void onStart() { super.onStart(); throw new MyError(); }
73      }
74  
75      static class FailingThreadFactory
# Line 256 | Line 258 | public class ForkJoinPoolTest extends JS
258       */
259      public void testSetUncaughtExceptionHandler() throws InterruptedException {
260          final CountDownLatch uehInvoked = new CountDownLatch(1);
261 <        final Thread.UncaughtExceptionHandler eh =
261 >        final Thread.UncaughtExceptionHandler ueh =
262              new Thread.UncaughtExceptionHandler() {
263                  public void uncaughtException(Thread t, Throwable e) {
264 +                    threadAssertTrue(e instanceof MyError);
265 +                    threadAssertTrue(t instanceof FailingFJWSubclass);
266                      uehInvoked.countDown();
267                  }};
268          ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(),
269 <                                          eh, false);
270 <        try {
271 <            assertSame(eh, p.getUncaughtExceptionHandler());
269 >                                          ueh, false);
270 >        try (PoolCleaner cleaner = cleaner(p)) {
271 >            assertSame(ueh, p.getUncaughtExceptionHandler());
272              try {
273                  p.execute(new FibTask(8));
274 <                assertTrue(uehInvoked.await(MEDIUM_DELAY_MS, MILLISECONDS));
275 <            } catch (RejectedExecutionException ok) {
274 >                await(uehInvoked);
275 >            } finally {
276 >                p.shutdownNow(); // failure might have prevented processing task
277              }
273        } finally {
274            p.shutdownNow(); // failure might have prevented processing task
275            joinPool(p);
278          }
279      }
280  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines