--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2017/05/13 21:43:51 1.73 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2017/08/15 20:30:30 1.80 @@ -278,22 +278,32 @@ public class LinkedTransferQueueTest ext */ 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) {} + assertFalse(Thread.interrupted()); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); - await(aboutToWait); - waitForThreadToEnterWaitState(t); + await(pleaseInterrupt); + assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); checkEmpty(q); @@ -315,6 +325,7 @@ public class LinkedTransferQueueTest ext q.poll(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} + assertFalse(Thread.interrupted()); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); @@ -636,7 +647,7 @@ public class LinkedTransferQueueTest ext } /** - * A deserialized serialized queue has same elements in same order + * A deserialized/reserialized queue has same elements in same order */ public void testSerialization() throws Exception { Queue x = populatedQueue(SIZE); @@ -763,7 +774,7 @@ public class LinkedTransferQueueTest ext } /** - * transfer waits until a poll occurs. The transfered element + * transfer waits until a poll occurs. The transferred element * is returned by the associated poll. */ public void testTransfer2() throws InterruptedException { @@ -844,7 +855,7 @@ public class LinkedTransferQueueTest ext } /** - * transfer waits until a take occurs. The transfered element + * transfer waits until a take occurs. The transferred element * is returned by the associated take. */ public void testTransfer5() throws InterruptedException { @@ -961,7 +972,7 @@ public class LinkedTransferQueueTest ext }}); await(pleaseInterrupt); - assertThreadStaysAlive(t); + assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); checkEmpty(q);