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.74 by jsr166, Sat May 13 22:49:01 2017 UTC vs.
Revision 1.78 by jsr166, Sun May 14 01:30:34 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) {
764 >                for (int i = 0; i < SIZE; i++)
765                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
766 <                }
767 <                aboutToWait.countDown();
766 >
767 >                Thread.currentThread().interrupt();
768 >                try {
769 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
770 >                    shouldThrow();
771 >                } catch (InterruptedException success) {}
772 >                assertFalse(Thread.interrupted());
773 >
774 >                pleaseInterrupt.countDown();
775                  try {
776                      q.poll(LONG_DELAY_MS, MILLISECONDS);
777                      shouldThrow();
778 <                } catch (InterruptedException success) {
779 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
780 <                }
778 >                } catch (InterruptedException success) {}
779 >                assertFalse(Thread.interrupted());
780 >
781 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
782              }});
783  
784 <        await(aboutToWait);
784 >        await(pleaseInterrupt);
785          assertThreadBlocks(t, Thread.State.TIMED_WAITING);
786          t.interrupt();
787          awaitTermination(t);
# Line 891 | Line 900 | public class LinkedBlockingDequeTest ext
900                      q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
901                      shouldThrow();
902                  } catch (InterruptedException success) {}
903 +                assertFalse(Thread.interrupted());
904              }});
905  
906          await(pleaseInterrupt);
# Line 1059 | Line 1069 | public class LinkedBlockingDequeTest ext
1069          Thread t = newStartedThread(new CheckedRunnable() {
1070              public void realRun() throws InterruptedException {
1071                  long startTime = System.nanoTime();
1072 <                for (int i = 0; i < SIZE; ++i) {
1072 >                for (int i = 0; i < SIZE; i++)
1073                      assertEquals(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS));
1064                }
1074  
1075                  Thread.currentThread().interrupt();
1076                  try {
# Line 1076 | Line 1085 | public class LinkedBlockingDequeTest ext
1085                      shouldThrow();
1086                  } catch (InterruptedException success) {}
1087                  assertFalse(Thread.interrupted());
1088 +
1089                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1090              }});
1091  
# Line 1113 | Line 1123 | public class LinkedBlockingDequeTest ext
1123                      q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
1124                      shouldThrow();
1125                  } catch (InterruptedException success) {}
1126 +                assertFalse(Thread.interrupted());
1127                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1128              }});
1129  
# Line 1121 | Line 1132 | public class LinkedBlockingDequeTest ext
1132          assertTrue(q.offerFirst(zero, LONG_DELAY_MS, MILLISECONDS));
1133          assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1134          barrier.await();
1135 <        assertThreadStaysAlive(t);
1135 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1136          t.interrupt();
1137          awaitTermination(t);
1138      }
# Line 1325 | Line 1336 | public class LinkedBlockingDequeTest ext
1336          Thread t = newStartedThread(new CheckedRunnable() {
1337              public void realRun() throws InterruptedException {
1338                  long startTime = System.nanoTime();
1339 <                for (int i = 0; i < SIZE; ++i) {
1339 >                for (int i = 0; i < SIZE; i++)
1340                      assertEquals(SIZE - i - 1,
1341                                   q.pollLast(LONG_DELAY_MS, MILLISECONDS));
1331                }
1342  
1343                  Thread.currentThread().interrupt();
1344                  try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines