ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/LinkedBlockingDequeTest.java
(Generate patch)

Comparing jsr166/src/test/tck/LinkedBlockingDequeTest.java (file contents):
Revision 1.72 by jsr166, Sat May 13 22:17:12 2017 UTC vs.
Revision 1.77 by jsr166, Sun May 14 00:56:43 2017 UTC

# Line 663 | Line 663 | public class LinkedBlockingDequeTest ext
663                      q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
664                      shouldThrow();
665                  } catch (InterruptedException success) {}
666 +                assertFalse(Thread.interrupted());
667              }});
668  
669          await(pleaseInterrupt);
# Line 756 | Line 757 | public class LinkedBlockingDequeTest ext
757       */
758      public void testInterruptedTimedPoll() throws InterruptedException {
759          final BlockingQueue<Integer> q = populatedDeque(SIZE);
760 <        final CountDownLatch aboutToWait = new CountDownLatch(1);
760 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
761          Thread t = newStartedThread(new CheckedRunnable() {
762              public void realRun() throws InterruptedException {
763                  long startTime = System.nanoTime();
764                  for (int i = 0; i < SIZE; ++i) {
765                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
766                  }
767 <                aboutToWait.countDown();
767 >
768 >                pleaseInterrupt.countDown();
769                  try {
770                      q.poll(LONG_DELAY_MS, MILLISECONDS);
771                      shouldThrow();
772 <                } catch (InterruptedException success) {
773 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
774 <                }
772 >                } catch (InterruptedException success) {}
773 >                assertFalse(Thread.interrupted());
774 >
775 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
776              }});
777  
778 <        await(aboutToWait);
779 <        waitForThreadToEnterWaitState(t);
778 >        await(pleaseInterrupt);
779 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
780          t.interrupt();
781          awaitTermination(t);
782          checkEmpty(q);
# Line 891 | Line 894 | public class LinkedBlockingDequeTest ext
894                      q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
895                      shouldThrow();
896                  } catch (InterruptedException success) {}
897 +                assertFalse(Thread.interrupted());
898              }});
899  
900          await(pleaseInterrupt);
# Line 1076 | Line 1080 | public class LinkedBlockingDequeTest ext
1080                      shouldThrow();
1081                  } catch (InterruptedException success) {}
1082                  assertFalse(Thread.interrupted());
1083 +
1084                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1085              }});
1086  
1087          await(pleaseInterrupt);
1088 <        assertThreadStaysAlive(t);
1088 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1089          t.interrupt();
1090          awaitTermination(t);
1091      }
# Line 1113 | Line 1118 | public class LinkedBlockingDequeTest ext
1118                      q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
1119                      shouldThrow();
1120                  } catch (InterruptedException success) {}
1121 +                assertFalse(Thread.interrupted());
1122                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1123              }});
1124  
# Line 1121 | Line 1127 | public class LinkedBlockingDequeTest ext
1127          assertTrue(q.offerFirst(zero, LONG_DELAY_MS, MILLISECONDS));
1128          assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1129          barrier.await();
1130 <        assertThreadStaysAlive(t);
1130 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1131          t.interrupt();
1132          awaitTermination(t);
1133      }
# Line 1348 | Line 1354 | public class LinkedBlockingDequeTest ext
1354              }});
1355  
1356          await(pleaseInterrupt);
1357 <        assertThreadStaysAlive(t);
1357 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1358          t.interrupt();
1359          awaitTermination(t);
1360          checkEmpty(q);
# Line 1394 | Line 1400 | public class LinkedBlockingDequeTest ext
1400          assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1401  
1402          barrier.await();
1403 <        assertThreadStaysAlive(t);
1403 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1404          t.interrupt();
1405          awaitTermination(t);
1406      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines