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

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.78 by jsr166, Sun Oct 4 03:52:33 2015 UTC vs.
Revision 1.79 by jsr166, Sun Oct 4 03:58:22 2015 UTC

# Line 1253 | Line 1253 | public class ThreadPoolExecutorSubclassT
1253       * execute using CallerRunsPolicy drops task on shutdown
1254       */
1255      public void testCallerRunsOnShutdown() {
1256 <        RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
1257 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1258 <
1256 >        final ThreadPoolExecutor p =
1257 >            new CustomTPE(1, 1,
1258 >                          LONG_DELAY_MS, MILLISECONDS,
1259 >                          new ArrayBlockingQueue<Runnable>(1),
1260 >                          new CustomTPE.CallerRunsPolicy());
1261          try { p.shutdown(); } catch (SecurityException ok) { return; }
1262          try (PoolCleaner cleaner = cleaner(p)) {
1263              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
# Line 1268 | Line 1270 | public class ThreadPoolExecutorSubclassT
1270       * execute using DiscardPolicy drops task on shutdown
1271       */
1272      public void testDiscardOnShutdown() {
1273 <        RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
1274 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1275 <
1273 >        final ThreadPoolExecutor p =
1274 >            new CustomTPE(1, 1,
1275 >                          LONG_DELAY_MS, MILLISECONDS,
1276 >                          new ArrayBlockingQueue<Runnable>(1),
1277 >                          new CustomTPE.DiscardPolicy());
1278          try { p.shutdown(); } catch (SecurityException ok) { return; }
1279 <        try {
1279 >        try (PoolCleaner cleaner = cleaner(p)) {
1280              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1281              p.execute(r);
1282              assertFalse(r.done);
1279        } finally {
1280            joinPool(p);
1283          }
1284      }
1285  
# Line 1285 | Line 1287 | public class ThreadPoolExecutorSubclassT
1287       * execute using DiscardOldestPolicy drops task on shutdown
1288       */
1289      public void testDiscardOldestOnShutdown() {
1290 <        RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
1291 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
1290 >        final ThreadPoolExecutor p =
1291 >            new CustomTPE(1, 1,
1292 >                          LONG_DELAY_MS, MILLISECONDS,
1293 >                          new ArrayBlockingQueue<Runnable>(1),
1294 >                          new CustomTPE.DiscardOldestPolicy());
1295  
1296          try { p.shutdown(); } catch (SecurityException ok) { return; }
1297 <        try {
1297 >        try (PoolCleaner cleaner = cleaner(p)) {
1298              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1299              p.execute(r);
1300              assertFalse(r.done);
1296        } finally {
1297            joinPool(p);
1301          }
1302      }
1303  
# Line 1302 | Line 1305 | public class ThreadPoolExecutorSubclassT
1305       * execute(null) throws NPE
1306       */
1307      public void testExecuteNull() {
1308 <        ThreadPoolExecutor p =
1309 <            new CustomTPE(1, 2, 1L, SECONDS,
1308 >        final ThreadPoolExecutor p =
1309 >            new CustomTPE(1, 2,
1310 >                          1L, SECONDS,
1311                            new ArrayBlockingQueue<Runnable>(10));
1312 <        try {
1313 <            p.execute(null);
1314 <            shouldThrow();
1315 <        } catch (NullPointerException success) {}
1316 <
1317 <        joinPool(p);
1312 >        try (PoolCleaner cleaner = cleaner(p)) {
1313 >            try {
1314 >                p.execute(null);
1315 >                shouldThrow();
1316 >            } catch (NullPointerException success) {}
1317 >        }
1318      }
1319  
1320      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines