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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.165 by jsr166, Mon Oct 5 01:10:09 2015 UTC vs.
Revision 1.168 by jsr166, Mon Oct 5 22:53:25 2015 UTC

# Line 776 | Line 776 | public class JSR166TestCase extends Test
776          public void close() { joinPool(pool); }
777      }
778  
779 +    /**
780 +     * An extension of PoolCleaner that has an action to release the pool.
781 +     */
782 +    class PoolCleanerWithReleaser extends PoolCleaner {
783 +        private final Runnable releaser;
784 +        public PoolCleanerWithReleaser(ExecutorService pool, Runnable releaser) {
785 +            super(pool);
786 +            this.releaser = releaser;
787 +        }
788 +        public void close() {
789 +            try {
790 +                releaser.run();
791 +            } finally {
792 +                super.close();
793 +            }
794 +        }
795 +    }
796 +
797      PoolCleaner cleaner(ExecutorService pool) {
798          return new PoolCleaner(pool);
799      }
800  
801 +    PoolCleaner cleaner(ExecutorService pool, Runnable releaser) {
802 +        return new PoolCleanerWithReleaser(pool, releaser);
803 +    }
804 +
805 +    PoolCleaner cleaner(ExecutorService pool, CountDownLatch latch) {
806 +        return new PoolCleanerWithReleaser(pool, releaser(latch));
807 +    }
808 +
809 +    Runnable releaser(final CountDownLatch latch) {
810 +        return new Runnable() { public void run() {
811 +            do { latch.countDown(); }
812 +            while (latch.getCount() > 0);
813 +        }};
814 +    }
815 +
816      /**
817       * Waits out termination of a thread pool or fails doing so.
818       */
# Line 793 | Line 826 | public class JSR166TestCase extends Test
826                  } finally {
827                      // last resort, for the benefit of subsequent tests
828                      pool.shutdownNow();
829 <                    pool.awaitTermination(SMALL_DELAY_MS, MILLISECONDS);
829 >                    pool.awaitTermination(MEDIUM_DELAY_MS, MILLISECONDS);
830                  }
831              }
832          } catch (SecurityException ok) {
# Line 1170 | Line 1203 | public class JSR166TestCase extends Test
1203          } finally {
1204              if (t.getState() != Thread.State.TERMINATED) {
1205                  t.interrupt();
1206 <                fail("Test timed out");
1206 >                threadFail("Test timed out");
1207              }
1208          }
1209      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines