--- jsr166/src/test/tck/ForkJoinTaskTest.java 2010/11/22 07:50:50 1.27 +++ jsr166/src/test/tck/ForkJoinTaskTest.java 2011/03/15 19:47:06 1.31 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.concurrent.ExecutionException; import java.util.concurrent.CancellationException; @@ -93,7 +93,23 @@ public class ForkJoinTaskTest extends JS assertFalse(a.isCompletedAbnormally()); assertNull(a.getException()); assertSame(expected, a.getRawResult()); - assertSame(expected, a.join()); + + { + Thread.currentThread().interrupt(); + long t0 = System.nanoTime(); + assertSame(expected, a.join()); + assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + Thread.interrupted(); + } + + { + Thread.currentThread().interrupt(); + long t0 = System.nanoTime(); + a.quietlyJoin(); // should be no-op + assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + Thread.interrupted(); + } + assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); try { @@ -115,10 +131,18 @@ public class ForkJoinTaskTest extends JS assertTrue(a.cancel(true)); try { + Thread.currentThread().interrupt(); a.join(); shouldThrow(); } catch (CancellationException success) { } catch (Throwable fail) { threadUnexpectedException(fail); } + Thread.interrupted(); + + { + long t0 = System.nanoTime(); + a.quietlyJoin(); // should be no-op + assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); + } try { a.get(); @@ -138,30 +162,38 @@ public class ForkJoinTaskTest extends JS assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); assertTrue(a.isCompletedAbnormally()); - assertSame(t, a.getException()); + assertSame(t.getClass(), a.getException().getClass()); assertNull(a.getRawResult()); assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); try { + Thread.currentThread().interrupt(); a.join(); shouldThrow(); } catch (Throwable expected) { - assertSame(t, expected); + assertSame(t.getClass(), expected.getClass()); + } + Thread.interrupted(); + + { + long t0 = System.nanoTime(); + a.quietlyJoin(); // should be no-op + assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); } try { a.get(); shouldThrow(); } catch (ExecutionException success) { - assertSame(t, success.getCause()); + assertSame(t.getClass(), success.getCause().getClass()); } catch (Throwable fail) { threadUnexpectedException(fail); } try { a.get(5L, SECONDS); shouldThrow(); } catch (ExecutionException success) { - assertSame(t, success.getCause()); + assertSame(t.getClass(), success.getCause().getClass()); } catch (Throwable fail) { threadUnexpectedException(fail); } } @@ -173,7 +205,7 @@ public class ForkJoinTaskTest extends JS * differently than supplied Recursive forms. */ - static final class FJException extends RuntimeException { + public static final class FJException extends RuntimeException { FJException() { super(); } }