--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2017/03/25 21:41:10 1.72 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2017/08/15 20:30:30 1.80 @@ -209,9 +209,7 @@ public class LinkedTransferQueueTest ext final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.take()); - } + for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); Thread.currentThread().interrupt(); try { @@ -229,7 +227,7 @@ public class LinkedTransferQueueTest ext }}); await(pleaseInterrupt); - assertThreadStaysAlive(t); + assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); } @@ -280,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); @@ -317,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); }}); @@ -638,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); @@ -765,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 { @@ -846,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 { @@ -963,7 +972,7 @@ public class LinkedTransferQueueTest ext }}); await(pleaseInterrupt); - assertThreadStaysAlive(t); + assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); checkEmpty(q);