--- jsr166/src/test/tck/PriorityBlockingQueueTest.java 2017/05/13 22:49:01 1.74 +++ jsr166/src/test/tck/PriorityBlockingQueueTest.java 2017/05/29 22:44:27 1.78 @@ -90,7 +90,7 @@ public class PriorityBlockingQueueTest e } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IllegalArgumentException if capacity argument nonpositive */ public void testConstructor2() { try { @@ -229,7 +229,7 @@ public class PriorityBlockingQueueTest e } /** - * addAll(this) throws IAE + * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { PriorityBlockingQueue q = populatedQueue(SIZE); @@ -302,7 +302,7 @@ public class PriorityBlockingQueueTest e /** * timed offer does not time out */ - public void testTimedOffer() throws InterruptedException { + public void testTimedOffer() { final PriorityBlockingQueue q = new PriorityBlockingQueue(2); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { @@ -400,23 +400,31 @@ public class PriorityBlockingQueueTest e */ public void testInterruptedTimedPoll() throws InterruptedException { final BlockingQueue q = populatedQueue(SIZE); - final CountDownLatch aboutToWait = new CountDownLatch(1); + final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { long startTime = System.nanoTime(); - for (int i = 0; i < SIZE; ++i) { + for (int i = 0; i < SIZE; i++) assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); - } - aboutToWait.countDown(); + + Thread.currentThread().interrupt(); + try { + q.poll(LONG_DELAY_MS, MILLISECONDS); + shouldThrow(); + } catch (InterruptedException success) {} + assertFalse(Thread.interrupted()); + + pleaseInterrupt.countDown(); try { q.poll(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); - } catch (InterruptedException success) { - assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); - } + } catch (InterruptedException success) {} + assertFalse(Thread.interrupted()); + + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); - await(aboutToWait); + await(pleaseInterrupt); assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t);