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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.1 by dl, Fri Jul 31 23:02:49 2009 UTC vs.
Revision 1.23 by jsr166, Sat Sep 11 19:04:12 2010 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/licenses/publicdomain
5   */
6  
7
7   import junit.framework.*;
8   import java.util.*;
9 < import java.util.concurrent.*;
9 > import java.util.concurrent.Executor;
10 > import java.util.concurrent.Executors;
11 > import java.util.concurrent.ExecutorService;
12 > import java.util.concurrent.AbstractExecutorService;
13 > import java.util.concurrent.CountDownLatch;
14 > import java.util.concurrent.Callable;
15 > import java.util.concurrent.Future;
16 > import java.util.concurrent.ExecutionException;
17 > import java.util.concurrent.CancellationException;
18 > import java.util.concurrent.RejectedExecutionException;
19 > import java.util.concurrent.ForkJoinPool;
20 > import java.util.concurrent.ForkJoinTask;
21 > import java.util.concurrent.ForkJoinWorkerThread;
22 > import java.util.concurrent.RecursiveAction;
23 > import java.util.concurrent.RecursiveTask;
24 > import java.util.concurrent.TimeUnit;
25   import java.util.concurrent.locks.*;
26   import java.security.*;
27  
28 < public class ForkJoinPoolTest extends JSR166TestCase{
28 > public class ForkJoinPoolTest extends JSR166TestCase {
29      public static void main(String[] args) {
30 <        junit.textui.TestRunner.run (suite());
30 >        junit.textui.TestRunner.run(suite());
31      }
32 +
33      public static Test suite() {
34          return new TestSuite(ForkJoinPoolTest.class);
35      }
# Line 25 | Line 40 | public class ForkJoinPoolTest extends JS
40       * 1. shutdown and related methods are tested via super.joinPool.
41       *
42       * 2. newTaskFor and adapters are tested in submit/invoke tests
43 <     *
43 >     *
44       * 3. We cannot portably test monitoring methods such as
45       * getStealCount() since they rely ultimately on random task
46       * stealing that may cause tasks not to be stolen/propagated
47       * across threads, especially on uniprocessors.
48 <     *
48 >     *
49       * 4. There are no independently testable ForkJoinWorkerThread
50       * methods, but they are covered here and in task tests.
51       */
# Line 38 | Line 53 | public class ForkJoinPoolTest extends JS
53      // Some classes to test extension and factory methods
54  
55      static class MyHandler implements Thread.UncaughtExceptionHandler {
56 <        int catches = 0;
56 >        volatile int catches = 0;
57          public void uncaughtException(Thread t, Throwable e) {
58              ++catches;
59          }
# Line 47 | Line 62 | public class ForkJoinPoolTest extends JS
62      // to test handlers
63      static class FailingFJWSubclass extends ForkJoinWorkerThread {
64          public FailingFJWSubclass(ForkJoinPool p) { super(p) ; }
65 <        protected void onStart() { throw new Error(); }
65 >        protected void onStart() { super.onStart(); throw new Error(); }
66      }
67  
68 <    static class FailingThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
69 <        int calls = 0;
70 <        public ForkJoinWorkerThread newThread(ForkJoinPool p){
68 >    static class FailingThreadFactory
69 >            implements ForkJoinPool.ForkJoinWorkerThreadFactory {
70 >        volatile int calls = 0;
71 >        public ForkJoinWorkerThread newThread(ForkJoinPool p) {
72              if (++calls > 1) return null;
73              return new FailingFJWSubclass(p);
74 <        }  
74 >        }
75      }
76  
77 <    static class SubFJP extends ForkJoinPool { // to expose protected
77 >    static class SubFJP extends ForkJoinPool { // to expose protected
78          SubFJP() { super(1); }
79          public int drainTasksTo(Collection<? super ForkJoinTask<?>> c) {
80              return super.drainTasksTo(c);
# Line 83 | Line 99 | public class ForkJoinPoolTest extends JS
99      }
100  
101      // A simple recursive task for testing
102 <    static final class FibTask extends RecursiveTask<Integer> {
102 >    static final class FibTask extends RecursiveTask<Integer> {
103          final int number;
104          FibTask(int n) { number = n; }
105          public Integer compute() {
# Line 97 | Line 113 | public class ForkJoinPoolTest extends JS
113      }
114  
115      // A failing task for testing
116 <    static final class FailingTask extends ForkJoinTask<Void> {
116 >    static final class FailingTask extends ForkJoinTask<Void> {
117          public final Void getRawResult() { return null; }
118          protected final void setRawResult(Void mustBeNull) { }
119          protected final boolean exec() { throw new Error(); }
# Line 105 | Line 121 | public class ForkJoinPoolTest extends JS
121      }
122  
123      // Fib needlessly using locking to test ManagedBlockers
124 <    static final class LockingFibTask extends RecursiveTask<Integer> {
124 >    static final class LockingFibTask extends RecursiveTask<Integer> {
125          final int number;
126          final ManagedLocker locker;
127          final ReentrantLock lock;
128 <        LockingFibTask(int n, ManagedLocker locker, ReentrantLock lock) {
129 <            number = n;
128 >        LockingFibTask(int n, ManagedLocker locker, ReentrantLock lock) {
129 >            number = n;
130              this.locker = locker;
131              this.lock = lock;
132          }
# Line 119 | Line 135 | public class ForkJoinPoolTest extends JS
135              LockingFibTask f1 = null;
136              LockingFibTask f2 = null;
137              locker.block();
138 <            n = number;
138 >            n = number;
139              if (n > 1) {
140                  f1 = new LockingFibTask(n - 1, locker, lock);
141                  f2 = new LockingFibTask(n - 2, locker, lock);
# Line 134 | Line 150 | public class ForkJoinPoolTest extends JS
150          }
151      }
152  
153 <    /**
154 <     * Succesfully constructed pool reports default factory,
153 >    /**
154 >     * Successfully constructed pool reports default factory,
155       * parallelism and async mode policies, no active threads or
156       * tasks, and quiescent running state.
157       */
158      public void testDefaultInitialState() {
159 <        ForkJoinPool p = null;
159 >        ForkJoinPool p = new ForkJoinPool(1);
160          try {
161 <            p = new ForkJoinPool(1);
162 <            assertTrue(p.getFactory() == ForkJoinPool.defaultForkJoinWorkerThreadFactory);
161 >            assertTrue(p.getFactory() ==
162 >                       ForkJoinPool.defaultForkJoinWorkerThreadFactory);
163              assertTrue(p.isQuiescent());
148            assertTrue(p.getMaintainsParallelism());
164              assertFalse(p.getAsyncMode());
165              assertTrue(p.getActiveThreadCount() == 0);
166              assertTrue(p.getStealCount() == 0);
# Line 160 | Line 175 | public class ForkJoinPoolTest extends JS
175          }
176      }
177  
178 <    /**
179 <     * Constructor throws if size argument is less than zero
178 >    /**
179 >     * Constructor throws if size argument is less than zero
180       */
181      public void testConstructor1() {
182          try {
183              new ForkJoinPool(-1);
184              shouldThrow();
185 <        }
171 <        catch (IllegalArgumentException success){}
185 >        } catch (IllegalArgumentException success) {}
186      }
187  
188 <    /**
189 <     * Constructor throws if factory argument is null
188 >    /**
189 >     * Constructor throws if factory argument is null
190       */
191      public void testConstructor2() {
192          try {
193 <            new ForkJoinPool(1, null);
193 >            new ForkJoinPool(1, null, null, false);
194              shouldThrow();
195 <        }
182 <        catch (NullPointerException success){}  
195 >        } catch (NullPointerException success) {}
196      }
197  
198  
199 <    /**
200 <     * getParallelism returns size set in constructor
199 >    /**
200 >     * getParallelism returns size set in constructor
201       */
202      public void testGetParallelism() {
203 <        ForkJoinPool p = null;
191 <        try {
192 <            p = new ForkJoinPool(1);
193 <            assertTrue(p.getParallelism() == 1);
194 <        } finally {
195 <            joinPool(p);
196 <        }
197 <    }
198 <
199 <    /**
200 <     * setParallelism changes reported parallelism level.
201 <     */
202 <    public void testSetParallelism() {
203 <        ForkJoinPool p = null;
204 <        try {
205 <            p = new ForkJoinPool(1);
206 <            assertTrue(p.getParallelism() == 1);
207 <            p.setParallelism(2);
208 <            assertTrue(p.getParallelism() == 2);
209 <        } finally {
210 <            joinPool(p);
211 <        }
212 <    }
213 <
214 <    /**
215 <     * setParallelism with argument <= 0 throws exception
216 <     */
217 <    public void testSetParallelism2() {
218 <        ForkJoinPool p = null;
203 >        ForkJoinPool p = new ForkJoinPool(1);
204          try {
220            p = new ForkJoinPool(1);
205              assertTrue(p.getParallelism() == 1);
222            p.setParallelism(-2);
223            shouldThrow();
224        }catch (IllegalArgumentException success){
206          } finally {
207              joinPool(p);
208          }
209      }
210  
211 <    /**
211 >    /**
212       * getPoolSize returns number of started workers.
213       */
214      public void testGetPoolSize() {
215 <        ForkJoinPool p = null;
215 >        ForkJoinPool p = new ForkJoinPool(1);
216          try {
217 <            p = new ForkJoinPool(1);
237 <            assertTrue(p.getPoolSize() == 0);
217 >            assertTrue(p.getActiveThreadCount() == 0);
218              Future<String> future = p.submit(new StringTask());
219              assertTrue(p.getPoolSize() == 1);
240
241        } finally {
242            joinPool(p);
243        }
244    }
245
246    /**
247     * setMaximumPoolSize changes size reported by getMaximumPoolSize.
248     */
249    public void testSetMaximumPoolSize() {
250        ForkJoinPool p = null;
251        try {
252            p = new ForkJoinPool(1);
253            p.setMaximumPoolSize(2);
254            assertTrue(p.getMaximumPoolSize() == 2);
255        } finally {
256            joinPool(p);
257        }
258    }
259
260    /**
261     * setMaximumPoolSize with argument <= 0 throws exception
262     */
263    public void testSetMaximumPoolSize2() {
264        ForkJoinPool p = null;
265        try {
266            p = new ForkJoinPool(1);
267            p.setMaximumPoolSize(-2);
268            shouldThrow();
269        }catch (IllegalArgumentException success){
270        } finally {
271            joinPool(p);
272        }
273    }
274
275    /**
276     * setMaintainsParallelism changes policy reported by
277     * getMaintainsParallelism.
278     */
279    public void testSetMaintainsParallelism() {
280        ForkJoinPool p = null;
281        try {
282            p = new ForkJoinPool(1);
283            p.setMaintainsParallelism(false);
284            assertFalse(p.getMaintainsParallelism());
285        } finally {
286            joinPool(p);
287        }
288    }
289    
290    /**
291     * setAsyncMode changes policy reported by
292     * getAsyncMode.
293     */
294    public void testSetAsyncMode() {
295        ForkJoinPool p = null;
296        try {
297            p = new ForkJoinPool(1);
298            p.setAsyncMode(true);
299            assertTrue(p.getAsyncMode());
220          } finally {
221              joinPool(p);
222          }
223      }
224  
225 <    /**
225 >    /**
226       * setUncaughtExceptionHandler changes handler for uncaught exceptions.
227       *
228       * Additionally tests: Overriding ForkJoinWorkerThread.onStart
229       * performs its defined action
230       */
231 <    public void testSetUncaughtExceptionHandler() {
232 <        ForkJoinPool p = null;
231 >    public void testSetUncaughtExceptionHandler() throws InterruptedException {
232 >        MyHandler eh = new MyHandler();
233 >        ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(), eh, false);
234          try {
235 <            p = new ForkJoinPool(1, new FailingThreadFactory());
315 <            MyHandler eh = new MyHandler();
316 <            p.setUncaughtExceptionHandler(eh);
317 <            assertEquals(eh, p.getUncaughtExceptionHandler());
235 >            assert(eh == p.getUncaughtExceptionHandler());
236              p.execute(new FailingTask());
237              Thread.sleep(MEDIUM_DELAY_MS);
238              assertTrue(eh.catches > 0);
321        } catch(InterruptedException e){
322            unexpectedException();
239          } finally {
240 +            p.shutdownNow();
241              joinPool(p);
242          }
243      }
244  
245 <    /**
329 <     * setUncaughtExceptionHandler of null removes handler
330 <     */
331 <    public void testSetUncaughtExceptionHandler2() {
332 <        ForkJoinPool p = null;
333 <        try {
334 <            p = new ForkJoinPool(1);
335 <            p.setUncaughtExceptionHandler(null);
336 <            assertNull(p.getUncaughtExceptionHandler());
337 <        } finally {
338 <            joinPool(p);
339 <        }
340 <    }
341 <
342 <
343 <    /**
245 >    /**
246       * After invoking a single task, isQuiescent is true,
247       * queues are empty, threads are not active, and
248       * construction parameters continue to hold
249       */
250 <    public void testisQuiescent() {
251 <        ForkJoinPool p = null;
250 >    public void testisQuiescent() throws InterruptedException {
251 >        ForkJoinPool p = new ForkJoinPool(2);
252          try {
351            p = new ForkJoinPool(2);
253              p.invoke(new FibTask(20));
254 <            assertTrue(p.getFactory() == ForkJoinPool.defaultForkJoinWorkerThreadFactory);
254 >            assertTrue(p.getFactory() ==
255 >                       ForkJoinPool.defaultForkJoinWorkerThreadFactory);
256              Thread.sleep(MEDIUM_DELAY_MS);
257              assertTrue(p.isQuiescent());
356            assertTrue(p.getMaintainsParallelism());
258              assertFalse(p.getAsyncMode());
259              assertTrue(p.getActiveThreadCount() == 0);
260              assertTrue(p.getQueuedTaskCount() == 0);
# Line 362 | Line 263 | public class ForkJoinPoolTest extends JS
263              assertFalse(p.isShutdown());
264              assertFalse(p.isTerminating());
265              assertFalse(p.isTerminated());
365        } catch(InterruptedException e){
366            unexpectedException();
266          } finally {
267              joinPool(p);
268          }
# Line 372 | Line 271 | public class ForkJoinPoolTest extends JS
271      /**
272       * Completed submit(ForkJoinTask) returns result
273       */
274 <    public void testSubmitForkJoinTask() {
275 <        ForkJoinPool p = null;
274 >    public void testSubmitForkJoinTask() throws Throwable {
275 >        ForkJoinPool p = new ForkJoinPool(1);
276          try {
378            p = new ForkJoinPool(1);
277              ForkJoinTask<Integer> f = p.submit(new FibTask(8));
278              int r = f.get();
279              assertTrue(r == 21);
382        } catch (ExecutionException ex) {
383            unexpectedException();
384        } catch (InterruptedException ex) {
385            unexpectedException();
280          } finally {
281              joinPool(p);
282          }
# Line 392 | Line 286 | public class ForkJoinPoolTest extends JS
286       * A task submitted after shutdown is rejected
287       */
288      public void testSubmitAfterShutdown() {
289 <        ForkJoinPool p = null;
289 >        ForkJoinPool p = new ForkJoinPool(1);
290          try {
397            p = new ForkJoinPool(1);
291              p.shutdown();
292              assertTrue(p.isShutdown());
293              ForkJoinTask<Integer> f = p.submit(new FibTask(8));
# Line 408 | Line 301 | public class ForkJoinPoolTest extends JS
301      /**
302       * Pool maintains parallelism when using ManagedBlocker
303       */
304 <    public void testBlockingForkJoinTask() {
305 <        ForkJoinPool p = null;
304 >    public void testBlockingForkJoinTask() throws Throwable {
305 >        ForkJoinPool p = new ForkJoinPool(4);
306          try {
414            p = new ForkJoinPool(4);
307              ReentrantLock lock = new ReentrantLock();
308              ManagedLocker locker = new ManagedLocker(lock);
309              ForkJoinTask<Integer> f = new LockingFibTask(30, locker, lock);
310              p.execute(f);
419            assertTrue(p.getPoolSize() >= 4);
311              int r = f.get();
312 <            assertTrue(r ==  832040);
422 <        } catch (ExecutionException ex) {
423 <            unexpectedException();
424 <        } catch (InterruptedException ex) {
425 <            unexpectedException();
312 >            assertTrue(r == 832040);
313          } finally {
314 <            joinPool(p);
314 >            p.shutdownNow(); // don't wait out shutdown
315          }
316      }
317  
# Line 432 | Line 319 | public class ForkJoinPoolTest extends JS
319       * pollSubmission returns unexecuted submitted task, if present
320       */
321      public void testPollSubmission() {
322 <        SubFJP p = null;
322 >        SubFJP p = new SubFJP();
323          try {
437            p = new SubFJP();
324              ForkJoinTask a = p.submit(new MediumRunnable());
325              ForkJoinTask b = p.submit(new MediumRunnable());
326              ForkJoinTask c = p.submit(new MediumRunnable());
# Line 450 | Line 336 | public class ForkJoinPoolTest extends JS
336       * drainTasksTo transfers unexecuted submitted tasks, if present
337       */
338      public void testDrainTasksTo() {
339 <        SubFJP p = null;
339 >        SubFJP p = new SubFJP();
340          try {
455            p = new SubFJP();
341              ForkJoinTask a = p.submit(new MediumRunnable());
342              ForkJoinTask b = p.submit(new MediumRunnable());
343              ForkJoinTask c = p.submit(new MediumRunnable());
# Line 468 | Line 353 | public class ForkJoinPoolTest extends JS
353          }
354      }
355  
356 <    
356 >
357      // FJ Versions of AbstractExecutorService tests
358  
359      /**
360       * execute(runnable) runs it to completion
361       */
362 <    public void testExecuteRunnable() {
362 >    public void testExecuteRunnable() throws Throwable {
363 >        ExecutorService e = new ForkJoinPool(1);
364          try {
479            ExecutorService e = new ForkJoinPool(1);
365              TrackedShortRunnable task = new TrackedShortRunnable();
366              assertFalse(task.done);
367              Future<?> future = e.submit(task);
368              future.get();
369              assertTrue(task.done);
370 <        }
371 <        catch (ExecutionException ex) {
487 <            unexpectedException();
488 <        }
489 <        catch (InterruptedException ex) {
490 <            unexpectedException();
370 >        } finally {
371 >            joinPool(e);
372          }
373      }
374  
# Line 495 | Line 376 | public class ForkJoinPoolTest extends JS
376      /**
377       * Completed submit(callable) returns result
378       */
379 <    public void testSubmitCallable() {
379 >    public void testSubmitCallable() throws Throwable {
380 >        ExecutorService e = new ForkJoinPool(1);
381          try {
500            ExecutorService e = new ForkJoinPool(1);
382              Future<String> future = e.submit(new StringTask());
383              String result = future.get();
384              assertSame(TEST_STRING, result);
385 <        }
386 <        catch (ExecutionException ex) {
506 <            unexpectedException();
507 <        }
508 <        catch (InterruptedException ex) {
509 <            unexpectedException();
385 >        } finally {
386 >            joinPool(e);
387          }
388      }
389  
390      /**
391       * Completed submit(runnable) returns successfully
392       */
393 <    public void testSubmitRunnable() {
393 >    public void testSubmitRunnable() throws Throwable {
394 >        ExecutorService e = new ForkJoinPool(1);
395          try {
518            ExecutorService e = new ForkJoinPool(1);
396              Future<?> future = e.submit(new NoOpRunnable());
397              future.get();
398              assertTrue(future.isDone());
399 <        }
400 <        catch (ExecutionException ex) {
524 <            unexpectedException();
525 <        }
526 <        catch (InterruptedException ex) {
527 <            unexpectedException();
399 >        } finally {
400 >            joinPool(e);
401          }
402      }
403  
404      /**
405       * Completed submit(runnable, result) returns result
406       */
407 <    public void testSubmitRunnable2() {
407 >    public void testSubmitRunnable2() throws Throwable {
408 >        ExecutorService e = new ForkJoinPool(1);
409          try {
536            ExecutorService e = new ForkJoinPool(1);
410              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
411              String result = future.get();
412              assertSame(TEST_STRING, result);
413 <        }
414 <        catch (ExecutionException ex) {
542 <            unexpectedException();
543 <        }
544 <        catch (InterruptedException ex) {
545 <            unexpectedException();
413 >        } finally {
414 >            joinPool(e);
415          }
416      }
417  
# Line 550 | Line 419 | public class ForkJoinPoolTest extends JS
419      /**
420       * A submitted privileged action to completion
421       */
422 <    public void testSubmitPrivilegedAction() {
422 >    public void testSubmitPrivilegedAction() throws Throwable {
423          Policy savedPolicy = null;
424          try {
425              savedPolicy = Policy.getPolicy();
# Line 558 | Line 427 | public class ForkJoinPoolTest extends JS
427              policy.addPermission(new RuntimePermission("getContextClassLoader"));
428              policy.addPermission(new RuntimePermission("setContextClassLoader"));
429              Policy.setPolicy(policy);
430 <        } catch(AccessControlException ok) {
430 >        } catch (AccessControlException ok) {
431              return;
432          }
433 +
434          try {
435              ExecutorService e = new ForkJoinPool(1);
436 <            Future future = e.submit(Executors.callable(new PrivilegedAction() {
436 >            try {
437 >                Future future = e.submit(Executors.callable(new PrivilegedAction() {
438                      public Object run() {
439                          return TEST_STRING;
440                      }}));
441  
442 <            Object result = future.get();
443 <            assertSame(TEST_STRING, result);
444 <        }
445 <        catch (ExecutionException ex) {
575 <            unexpectedException();
576 <        }
577 <        catch (InterruptedException ex) {
578 <            unexpectedException();
579 <        }
580 <        finally {
581 <            try {
582 <                Policy.setPolicy(savedPolicy);
583 <            } catch(AccessControlException ok) {
584 <                return;
442 >                Object result = future.get();
443 >                assertSame(TEST_STRING, result);
444 >            } finally {
445 >                joinPool(e);
446              }
447 +        } finally {
448 +            Policy.setPolicy(savedPolicy);
449          }
450      }
451  
452      /**
453       * A submitted a privileged exception action runs to completion
454       */
455 <    public void testSubmitPrivilegedExceptionAction() {
455 >    public void testSubmitPrivilegedExceptionAction() throws Throwable {
456          Policy savedPolicy = null;
457          try {
458              savedPolicy = Policy.getPolicy();
# Line 597 | Line 460 | public class ForkJoinPoolTest extends JS
460              policy.addPermission(new RuntimePermission("getContextClassLoader"));
461              policy.addPermission(new RuntimePermission("setContextClassLoader"));
462              Policy.setPolicy(policy);
463 <        } catch(AccessControlException ok) {
463 >        } catch (AccessControlException ok) {
464              return;
465          }
466  
467          try {
468              ExecutorService e = new ForkJoinPool(1);
469 <            Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
469 >            try {
470 >                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
471                      public Object run() {
472                          return TEST_STRING;
473                      }}));
474  
475 <            Object result = future.get();
476 <            assertSame(TEST_STRING, result);
477 <        }
478 <        catch (ExecutionException ex) {
479 <            unexpectedException();
480 <        }
617 <        catch (InterruptedException ex) {
618 <            unexpectedException();
619 <        }
620 <        finally {
475 >                Object result = future.get();
476 >                assertSame(TEST_STRING, result);
477 >            } finally {
478 >                joinPool(e);
479 >            }
480 >        } finally {
481              Policy.setPolicy(savedPolicy);
482          }
483      }
# Line 625 | Line 485 | public class ForkJoinPoolTest extends JS
485      /**
486       * A submitted failed privileged exception action reports exception
487       */
488 <    public void testSubmitFailedPrivilegedExceptionAction() {
488 >    public void testSubmitFailedPrivilegedExceptionAction() throws Throwable {
489          Policy savedPolicy = null;
490          try {
491              savedPolicy = Policy.getPolicy();
# Line 633 | Line 493 | public class ForkJoinPoolTest extends JS
493              policy.addPermission(new RuntimePermission("getContextClassLoader"));
494              policy.addPermission(new RuntimePermission("setContextClassLoader"));
495              Policy.setPolicy(policy);
496 <        } catch(AccessControlException ok) {
496 >        } catch (AccessControlException ok) {
497              return;
498          }
499  
640
500          try {
501              ExecutorService e = new ForkJoinPool(1);
502 <            Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
502 >            try {
503 >                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
504                      public Object run() throws Exception {
505                          throw new IndexOutOfBoundsException();
506                      }}));
507  
508 <            Object result = future.get();
509 <            shouldThrow();
510 <        }
511 <        catch (ExecutionException success) {
512 <        } catch (CancellationException success) {
513 <        } catch (InterruptedException ex) {
514 <            unexpectedException();
515 <        }
656 <        finally {
508 >                Object result = future.get();
509 >                shouldThrow();
510 >            } catch (ExecutionException success) {
511 >                assertTrue(success.getCause() instanceof IndexOutOfBoundsException);
512 >            } finally {
513 >                joinPool(e);
514 >            }
515 >        } finally {
516              Policy.setPolicy(savedPolicy);
517          }
518      }
519  
520      /**
521 <     * execute(null runnable) throws NPE
521 >     * execute(null runnable) throws NullPointerException
522       */
523      public void testExecuteNullRunnable() {
524 +        ExecutorService e = new ForkJoinPool(1);
525          try {
666            ExecutorService e = new ForkJoinPool(1);
526              TrackedShortRunnable task = null;
527              Future<?> future = e.submit(task);
528              shouldThrow();
529 <        }
530 <        catch (NullPointerException success) {
531 <        }
673 <        catch (Exception ex) {
674 <            unexpectedException();
529 >        } catch (NullPointerException success) {
530 >        } finally {
531 >            joinPool(e);
532          }
533      }
534  
535  
536      /**
537 <     * submit(null callable) throws NPE
537 >     * submit(null callable) throws NullPointerException
538       */
539      public void testSubmitNullCallable() {
540 +        ExecutorService e = new ForkJoinPool(1);
541          try {
684            ExecutorService e = new ForkJoinPool(1);
542              StringTask t = null;
543              Future<String> future = e.submit(t);
544              shouldThrow();
545 <        }
546 <        catch (NullPointerException success) {
547 <        }
691 <        catch (Exception ex) {
692 <            unexpectedException();
545 >        } catch (NullPointerException success) {
546 >        } finally {
547 >            joinPool(e);
548          }
549      }
550  
551  
552      /**
553 <     *  Blocking on submit(callable) throws InterruptedException if
554 <     *  caller interrupted.
553 >     * Blocking on submit(callable) throws InterruptedException if
554 >     * caller interrupted.
555       */
556 <    public void testInterruptedSubmit() {
556 >    public void testInterruptedSubmit() throws InterruptedException {
557          final ForkJoinPool p = new ForkJoinPool(1);
558 <        Thread t = new Thread(new Runnable() {
559 <                public void run() {
560 <                    try {
561 <                        p.submit(new Callable<Object>() {
562 <                                public Object call() {
563 <                                    try {
564 <                                        Thread.sleep(MEDIUM_DELAY_MS);
565 <                                        shouldThrow();
566 <                                    } catch(InterruptedException e){
567 <                                    }
568 <                                    return null;
569 <                                }
570 <                            }).get();
571 <                    } catch(InterruptedException success){
572 <                    } catch(Exception e) {
573 <                        unexpectedException();
574 <                    }
575 <
721 <                }
722 <            });
723 <        try {
724 <            t.start();
725 <            Thread.sleep(SHORT_DELAY_MS);
726 <            t.interrupt();
727 <        } catch(Exception e){
728 <            unexpectedException();
729 <        }
558 >
559 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
560 >            public void realRun() throws Throwable {
561 >                p.submit(new CheckedCallable<Object>() {
562 >                    public Object realCall() throws Throwable {
563 >                        try {
564 >                            Thread.sleep(MEDIUM_DELAY_MS);
565 >                        } catch (InterruptedException ok) {
566 >                        }
567 >                        return null;
568 >                    }}).get();
569 >            }});
570 >
571 >        t.start();
572 >        Thread.sleep(SHORT_DELAY_MS);
573 >        t.interrupt();
574 >        t.join();
575 >        p.shutdownNow();
576          joinPool(p);
577      }
578  
579      /**
580 <     *  get of submit(callable) throws ExecutionException if callable
581 <     *  throws exception
580 >     * get of submit(callable) throws ExecutionException if callable
581 >     * throws exception
582       */
583 <    public void testSubmitEE() {
583 >    public void testSubmitEE() throws Throwable {
584          ForkJoinPool p = new ForkJoinPool(1);
739
585          try {
586 <            Callable c = new Callable() {
587 <                    public Object call() {
588 <                        int i = 5/0;
589 <                        return Boolean.TRUE;
590 <                    }
746 <                };
747 <
748 <            for(int i =0; i < 5; i++){
749 <                p.submit(c).get();
750 <            }
751 <
586 >            p.submit(new Callable() {
587 >                public Object call() {
588 >                    int i = 5/0;
589 >                    return Boolean.TRUE;
590 >                }}).get();
591              shouldThrow();
592 +        } catch (ExecutionException success) {
593 +            assertTrue(success.getCause() instanceof ArithmeticException);
594 +        } finally {
595 +            joinPool(p);
596          }
754        catch(ExecutionException success){
755        } catch (CancellationException success) {
756        } catch(Exception e) {
757            unexpectedException();
758        }
759        joinPool(p);
597      }
598  
599      /**
600 <     * invokeAny(null) throws NPE
600 >     * invokeAny(null) throws NullPointerException
601       */
602 <    public void testInvokeAny1() {
602 >    public void testInvokeAny1() throws Throwable {
603          ExecutorService e = new ForkJoinPool(1);
604          try {
605              e.invokeAny(null);
606 +            shouldThrow();
607          } catch (NullPointerException success) {
770        } catch(Exception ex) {
771            unexpectedException();
608          } finally {
609              joinPool(e);
610          }
611      }
612  
613      /**
614 <     * invokeAny(empty collection) throws IAE
614 >     * invokeAny(empty collection) throws IllegalArgumentException
615       */
616 <    public void testInvokeAny2() {
616 >    public void testInvokeAny2() throws Throwable {
617          ExecutorService e = new ForkJoinPool(1);
618          try {
619              e.invokeAny(new ArrayList<Callable<String>>());
620 +            shouldThrow();
621          } catch (IllegalArgumentException success) {
785        } catch(Exception ex) {
786            unexpectedException();
622          } finally {
623              joinPool(e);
624          }
625      }
626  
627      /**
628 <     * invokeAny(c) throws NPE if c has null elements
628 >     * invokeAny(c) throws NullPointerException if c has a single null element
629       */
630 <    public void testInvokeAny3() {
630 >    public void testInvokeAny3() throws Throwable {
631          ExecutorService e = new ForkJoinPool(1);
632 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
633 +        l.add(null);
634          try {
798            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
799            l.add(new StringTask());
800            l.add(null);
635              e.invokeAny(l);
636 +            shouldThrow();
637          } catch (NullPointerException success) {
803        } catch(Exception ex) {
804            ex.printStackTrace();
805            unexpectedException();
638          } finally {
639              joinPool(e);
640          }
641      }
642  
643      /**
644 +     * invokeAny(c) throws NullPointerException if c has null elements
645 +     */
646 +    public void testInvokeAny4() throws Throwable {
647 +        CountDownLatch latch = new CountDownLatch(1);
648 +        ExecutorService e = new ForkJoinPool(1);
649 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
650 +        l.add(latchAwaitingStringTask(latch));
651 +        l.add(null);
652 +        try {
653 +            e.invokeAny(l);
654 +            shouldThrow();
655 +        } catch (NullPointerException success) {
656 +        } finally {
657 +            latch.countDown();
658 +            joinPool(e);
659 +        }
660 +    }
661 +
662 +    /**
663       * invokeAny(c) throws ExecutionException if no task in c completes
664       */
665 <    public void testInvokeAny4() {
665 >    public void testInvokeAny5() throws Throwable {
666          ExecutorService e = new ForkJoinPool(1);
667 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
668 +        l.add(new NPETask());
669          try {
817            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
818            l.add(new NPETask());
670              e.invokeAny(l);
671 <        } catch(ExecutionException success) {
672 <        } catch (CancellationException success) {
673 <        } catch(Exception ex) {
823 <            unexpectedException();
671 >            shouldThrow();
672 >        } catch (ExecutionException success) {
673 >            assertTrue(success.getCause() instanceof NullPointerException);
674          } finally {
675              joinPool(e);
676          }
# Line 829 | Line 679 | public class ForkJoinPoolTest extends JS
679      /**
680       * invokeAny(c) returns result of some task in c if at least one completes
681       */
682 <    public void testInvokeAny5() {
682 >    public void testInvokeAny6() throws Throwable {
683          ExecutorService e = new ForkJoinPool(1);
684          try {
685 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
685 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
686              l.add(new StringTask());
687              l.add(new StringTask());
688              String result = e.invokeAny(l);
689              assertSame(TEST_STRING, result);
840        } catch (ExecutionException success) {
841        } catch (CancellationException success) {
842        } catch(Exception ex) {
843            unexpectedException();
690          } finally {
691              joinPool(e);
692          }
693      }
694  
695      /**
696 <     * invokeAll(null) throws NPE
696 >     * invokeAll(null) throws NullPointerException
697       */
698 <    public void testInvokeAll1() {
698 >    public void testInvokeAll1() throws Throwable {
699          ExecutorService e = new ForkJoinPool(1);
700          try {
701              e.invokeAll(null);
702 +            shouldThrow();
703          } catch (NullPointerException success) {
857        } catch(Exception ex) {
858            unexpectedException();
704          } finally {
705              joinPool(e);
706          }
# Line 864 | Line 709 | public class ForkJoinPoolTest extends JS
709      /**
710       * invokeAll(empty collection) returns empty collection
711       */
712 <    public void testInvokeAll2() {
712 >    public void testInvokeAll2() throws InterruptedException {
713          ExecutorService e = new ForkJoinPool(1);
714          try {
715 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
715 >            List<Future<String>> r
716 >                = e.invokeAll(new ArrayList<Callable<String>>());
717              assertTrue(r.isEmpty());
872        } catch(Exception ex) {
873            unexpectedException();
718          } finally {
719              joinPool(e);
720          }
721      }
722  
723      /**
724 <     * invokeAll(c) throws NPE if c has null elements
724 >     * invokeAll(c) throws NullPointerException if c has null elements
725       */
726 <    public void testInvokeAll3() {
726 >    public void testInvokeAll3() throws InterruptedException {
727          ExecutorService e = new ForkJoinPool(1);
728 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
729 +        l.add(new StringTask());
730 +        l.add(null);
731          try {
885            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
886            l.add(new StringTask());
887            l.add(null);
732              e.invokeAll(l);
733 +            shouldThrow();
734          } catch (NullPointerException success) {
890        } catch(Exception ex) {
891            unexpectedException();
735          } finally {
736              joinPool(e);
737          }
738      }
739  
740      /**
741 <     * get of returned element of invokeAll(c) throws exception on failed task
741 >     * get of returned element of invokeAll(c) throws
742 >     * ExecutionException on failed task
743       */
744 <    public void testInvokeAll4() {
744 >    public void testInvokeAll4() throws Throwable {
745          ExecutorService e = new ForkJoinPool(1);
746 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
747 +        l.add(new NPETask());
748 +        List<Future<String>> futures = e.invokeAll(l);
749 +        assertEquals(1, futures.size());
750          try {
751 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
752 <            l.add(new NPETask());
753 <            List<Future<String>> result = e.invokeAll(l);
754 <            assertEquals(1, result.size());
907 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
908 <                it.next().get();
909 <        } catch(ExecutionException success) {
910 <        } catch (CancellationException success) {
911 <        } catch(Exception ex) {
912 <            ex.printStackTrace();
913 <            unexpectedException();
751 >            futures.get(0).get();
752 >            shouldThrow();
753 >        } catch (ExecutionException success) {
754 >            assertTrue(success.getCause() instanceof NullPointerException);
755          } finally {
756              joinPool(e);
757          }
# Line 919 | Line 760 | public class ForkJoinPoolTest extends JS
760      /**
761       * invokeAll(c) returns results of all completed tasks in c
762       */
763 <    public void testInvokeAll5() {
763 >    public void testInvokeAll5() throws Throwable {
764          ExecutorService e = new ForkJoinPool(1);
765          try {
766 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
766 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
767              l.add(new StringTask());
768              l.add(new StringTask());
769 <            List<Future<String>> result = e.invokeAll(l);
770 <            assertEquals(2, result.size());
771 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
772 <                assertSame(TEST_STRING, it.next().get());
932 <        } catch (ExecutionException success) {
933 <        } catch (CancellationException success) {
934 <        } catch(Exception ex) {
935 <            ex.printStackTrace();
936 <            unexpectedException();
769 >            List<Future<String>> futures = e.invokeAll(l);
770 >            assertEquals(2, futures.size());
771 >            for (Future<String> future : futures)
772 >                assertSame(TEST_STRING, future.get());
773          } finally {
774              joinPool(e);
775          }
# Line 941 | Line 777 | public class ForkJoinPoolTest extends JS
777  
778  
779      /**
780 <     * timed invokeAny(null) throws NPE
780 >     * timed invokeAny(null) throws NullPointerException
781       */
782 <    public void testTimedInvokeAny1() {
782 >    public void testTimedInvokeAny1() throws Throwable {
783          ExecutorService e = new ForkJoinPool(1);
784          try {
785              e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
786 +            shouldThrow();
787          } catch (NullPointerException success) {
951        } catch(Exception ex) {
952            ex.printStackTrace();
953            unexpectedException();
788          } finally {
789              joinPool(e);
790          }
791      }
792  
793      /**
794 <     * timed invokeAny(null time unit) throws NPE
794 >     * timed invokeAny(null time unit) throws NullPointerException
795       */
796 <    public void testTimedInvokeAnyNullTimeUnit() {
796 >    public void testTimedInvokeAnyNullTimeUnit() throws Throwable {
797          ExecutorService e = new ForkJoinPool(1);
798 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
799 +        l.add(new StringTask());
800          try {
965            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
966            l.add(new StringTask());
801              e.invokeAny(l, MEDIUM_DELAY_MS, null);
802 +            shouldThrow();
803          } catch (NullPointerException success) {
969        } catch(Exception ex) {
970            ex.printStackTrace();
971            unexpectedException();
804          } finally {
805              joinPool(e);
806          }
807      }
808  
809      /**
810 <     * timed invokeAny(empty collection) throws IAE
810 >     * timed invokeAny(empty collection) throws IllegalArgumentException
811       */
812 <    public void testTimedInvokeAny2() {
812 >    public void testTimedInvokeAny2() throws Throwable {
813          ExecutorService e = new ForkJoinPool(1);
814          try {
815 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
815 >            e.invokeAny(new ArrayList<Callable<String>>(),
816 >                        MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
817 >            shouldThrow();
818          } catch (IllegalArgumentException success) {
985        } catch(Exception ex) {
986            ex.printStackTrace();
987            unexpectedException();
819          } finally {
820              joinPool(e);
821          }
822      }
823  
824      /**
825 <     * timed invokeAny(c) throws NPE if c has null elements
825 >     * timed invokeAny(c) throws NullPointerException if c has null elements
826       */
827 <    public void testTimedInvokeAny3() {
827 >    public void testTimedInvokeAny3() throws Throwable {
828 >        CountDownLatch latch = new CountDownLatch(1);
829          ExecutorService e = new ForkJoinPool(1);
830 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
831 +        l.add(latchAwaitingStringTask(latch));
832 +        l.add(null);
833          try {
999            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1000            l.add(new StringTask());
1001            l.add(null);
834              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
835 +            shouldThrow();
836          } catch (NullPointerException success) {
1004        } catch(Exception ex) {
1005            ex.printStackTrace();
1006            unexpectedException();
837          } finally {
838 +            latch.countDown();
839              joinPool(e);
840          }
841      }
# Line 1012 | Line 843 | public class ForkJoinPoolTest extends JS
843      /**
844       * timed invokeAny(c) throws ExecutionException if no task completes
845       */
846 <    public void testTimedInvokeAny4() {
846 >    public void testTimedInvokeAny4() throws Throwable {
847          ExecutorService e = new ForkJoinPool(1);
848 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
849 +        l.add(new NPETask());
850          try {
1018            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1019            l.add(new NPETask());
851              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
852 <        } catch(ExecutionException success) {
853 <        } catch (CancellationException success) {
854 <        } catch(Exception ex) {
1024 <            ex.printStackTrace();
1025 <            unexpectedException();
852 >            shouldThrow();
853 >        } catch (ExecutionException success) {
854 >            assertTrue(success.getCause() instanceof NullPointerException);
855          } finally {
856              joinPool(e);
857          }
# Line 1031 | Line 860 | public class ForkJoinPoolTest extends JS
860      /**
861       * timed invokeAny(c) returns result of some task in c
862       */
863 <    public void testTimedInvokeAny5() {
863 >    public void testTimedInvokeAny5() throws Throwable {
864          ExecutorService e = new ForkJoinPool(1);
865          try {
866 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
866 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
867              l.add(new StringTask());
868              l.add(new StringTask());
869              String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
870              assertSame(TEST_STRING, result);
1042        } catch (ExecutionException success) {
1043        } catch (CancellationException success) {
1044        } catch(Exception ex) {
1045            ex.printStackTrace();
1046            unexpectedException();
871          } finally {
872              joinPool(e);
873          }
874      }
875  
876      /**
877 <     * timed invokeAll(null) throws NPE
877 >     * timed invokeAll(null) throws NullPointerException
878       */
879 <    public void testTimedInvokeAll1() {
879 >    public void testTimedInvokeAll1() throws Throwable {
880          ExecutorService e = new ForkJoinPool(1);
881          try {
882              e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
883 +            shouldThrow();
884          } catch (NullPointerException success) {
1060        } catch(Exception ex) {
1061            ex.printStackTrace();
1062            unexpectedException();
885          } finally {
886              joinPool(e);
887          }
888      }
889  
890      /**
891 <     * timed invokeAll(null time unit) throws NPE
891 >     * timed invokeAll(null time unit) throws NullPointerException
892       */
893 <    public void testTimedInvokeAllNullTimeUnit() {
893 >    public void testTimedInvokeAllNullTimeUnit() throws Throwable {
894          ExecutorService e = new ForkJoinPool(1);
895 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
896 +        l.add(new StringTask());
897          try {
1074            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1075            l.add(new StringTask());
898              e.invokeAll(l, MEDIUM_DELAY_MS, null);
899 +            shouldThrow();
900          } catch (NullPointerException success) {
1078        } catch(Exception ex) {
1079            ex.printStackTrace();
1080            unexpectedException();
901          } finally {
902              joinPool(e);
903          }
# Line 1086 | Line 906 | public class ForkJoinPoolTest extends JS
906      /**
907       * timed invokeAll(empty collection) returns empty collection
908       */
909 <    public void testTimedInvokeAll2() {
909 >    public void testTimedInvokeAll2() throws InterruptedException {
910          ExecutorService e = new ForkJoinPool(1);
911          try {
912 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
912 >            List<Future<String>> r
913 >                = e.invokeAll(new ArrayList<Callable<String>>(),
914 >                              MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
915              assertTrue(r.isEmpty());
1094        } catch(Exception ex) {
1095            ex.printStackTrace();
1096            unexpectedException();
916          } finally {
917              joinPool(e);
918          }
919      }
920  
921      /**
922 <     * timed invokeAll(c) throws NPE if c has null elements
922 >     * timed invokeAll(c) throws NullPointerException if c has null elements
923       */
924 <    public void testTimedInvokeAll3() {
924 >    public void testTimedInvokeAll3() throws InterruptedException {
925          ExecutorService e = new ForkJoinPool(1);
926 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
927 +        l.add(new StringTask());
928 +        l.add(null);
929          try {
1108            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1109            l.add(new StringTask());
1110            l.add(null);
930              e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
931 +            shouldThrow();
932          } catch (NullPointerException success) {
1113        } catch(Exception ex) {
1114            ex.printStackTrace();
1115            unexpectedException();
933          } finally {
934              joinPool(e);
935          }
# Line 1121 | Line 938 | public class ForkJoinPoolTest extends JS
938      /**
939       * get of returned element of invokeAll(c) throws exception on failed task
940       */
941 <    public void testTimedInvokeAll4() {
941 >    public void testTimedInvokeAll4() throws Throwable {
942          ExecutorService e = new ForkJoinPool(1);
943 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
944 +        l.add(new NPETask());
945 +        List<Future<String>> futures
946 +            = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
947 +        assertEquals(1, futures.size());
948          try {
949 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
950 <            l.add(new NPETask());
951 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
952 <            assertEquals(1, result.size());
1131 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1132 <                it.next().get();
1133 <        } catch(ExecutionException success) {
1134 <        } catch (CancellationException success) {
1135 <        } catch(Exception ex) {
1136 <            ex.printStackTrace();
1137 <            unexpectedException();
949 >            futures.get(0).get();
950 >            shouldThrow();
951 >        } catch (ExecutionException success) {
952 >            assertTrue(success.getCause() instanceof NullPointerException);
953          } finally {
954              joinPool(e);
955          }
# Line 1143 | Line 958 | public class ForkJoinPoolTest extends JS
958      /**
959       * timed invokeAll(c) returns results of all completed tasks in c
960       */
961 <    public void testTimedInvokeAll5() {
961 >    public void testTimedInvokeAll5() throws Throwable {
962          ExecutorService e = new ForkJoinPool(1);
963          try {
964 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
964 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
965              l.add(new StringTask());
966              l.add(new StringTask());
967 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
968 <            assertEquals(2, result.size());
969 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
970 <                assertSame(TEST_STRING, it.next().get());
971 <        } catch (ExecutionException success) {
1157 <        } catch (CancellationException success) {
1158 <        } catch(Exception ex) {
1159 <            ex.printStackTrace();
1160 <            unexpectedException();
967 >            List<Future<String>> futures
968 >                = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
969 >            assertEquals(2, futures.size());
970 >            for (Future<String> future : futures)
971 >                assertSame(TEST_STRING, future.get());
972          } finally {
973              joinPool(e);
974          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines