170 |
|
try { |
171 |
|
new ForkJoinPool(-1); |
172 |
|
shouldThrow(); |
173 |
< |
} |
174 |
< |
catch (IllegalArgumentException success) {} |
173 |
> |
} catch (IllegalArgumentException success) {} |
174 |
|
} |
175 |
|
|
176 |
|
/** |
180 |
|
try { |
181 |
|
new ForkJoinPool(1, null); |
182 |
|
shouldThrow(); |
183 |
< |
} catch (NullPointerException success) { |
185 |
< |
} |
183 |
> |
} catch (NullPointerException success) {} |
184 |
|
} |
185 |
|
|
186 |
|
|
414 |
|
int r = f.get(); |
415 |
|
assertTrue(r == 832040); |
416 |
|
} finally { |
417 |
< |
joinPool(p); |
417 |
> |
p.shutdownNow(); // don't wait out shutdown |
418 |
|
} |
419 |
|
} |
420 |
|
|
604 |
|
TrackedShortRunnable task = null; |
605 |
|
Future<?> future = e.submit(task); |
606 |
|
shouldThrow(); |
607 |
< |
} catch (NullPointerException success) { |
610 |
< |
} |
607 |
> |
} catch (NullPointerException success) {} |
608 |
|
} |
609 |
|
|
610 |
|
|
617 |
|
StringTask t = null; |
618 |
|
Future<String> future = e.submit(t); |
619 |
|
shouldThrow(); |
620 |
< |
} catch (NullPointerException success) { |
624 |
< |
} |
620 |
> |
} catch (NullPointerException success) {} |
621 |
|
} |
622 |
|
|
623 |
|
|
632 |
|
void realRun() throws Throwable { |
633 |
|
p.submit(new CheckedCallable<Object>() { |
634 |
|
public Object realCall() throws Throwable { |
635 |
< |
Thread.sleep(MEDIUM_DELAY_MS); |
635 |
> |
try { |
636 |
> |
Thread.sleep(MEDIUM_DELAY_MS); |
637 |
> |
} catch (InterruptedException ok) { |
638 |
> |
} |
639 |
|
return null; |
640 |
|
}}).get(); |
641 |
|
}}); |
643 |
|
t.start(); |
644 |
|
Thread.sleep(SHORT_DELAY_MS); |
645 |
|
t.interrupt(); |
646 |
+ |
t.join(); |
647 |
+ |
p.shutdownNow(); |
648 |
|
joinPool(p); |
649 |
|
} |
650 |
|
|
654 |
|
*/ |
655 |
|
public void testSubmitEE() throws Throwable { |
656 |
|
ForkJoinPool p = new ForkJoinPool(1); |
656 |
– |
|
657 |
|
try { |
658 |
< |
Callable c = new Callable() { |
659 |
< |
public Object call() { |
660 |
< |
int i = 5/0; |
661 |
< |
return Boolean.TRUE; |
662 |
< |
} |
663 |
< |
}; |
664 |
< |
|
665 |
< |
for (int i = 0; i < 5; i++) { |
666 |
< |
p.submit(c).get(); |
667 |
< |
} |
658 |
> |
p.submit(new Callable() { |
659 |
> |
public Object call() { |
660 |
> |
int i = 5/0; |
661 |
> |
return Boolean.TRUE; |
662 |
> |
}}).get(); |
663 |
|
shouldThrow(); |
664 |
< |
} catch (ExecutionException success) { |
665 |
< |
} |
664 |
> |
} catch (ExecutionException success) {} |
665 |
> |
|
666 |
|
joinPool(p); |
667 |
|
} |
668 |
|
|
695 |
|
} |
696 |
|
|
697 |
|
/** |
698 |
< |
* invokeAny(c) throws NullPointerException if c has null elements |
698 |
> |
* invokeAny(c) throws NullPointerException if c has a single null element |
699 |
|
*/ |
700 |
|
public void testInvokeAny3() throws Throwable { |
701 |
|
ExecutorService e = new ForkJoinPool(1); |
702 |
|
try { |
703 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
709 |
– |
l.add(new StringTask()); |
704 |
|
l.add(null); |
705 |
|
e.invokeAny(l); |
706 |
|
shouldThrow(); |
711 |
|
} |
712 |
|
|
713 |
|
/** |
714 |
< |
* invokeAny(c) throws ExecutionException if no task in c completes |
714 |
> |
* invokeAny(c) throws NullPointerException if c has null elements |
715 |
|
*/ |
716 |
|
public void testInvokeAny4() throws Throwable { |
717 |
|
ExecutorService e = new ForkJoinPool(1); |
718 |
|
try { |
719 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
720 |
+ |
l.add(new Callable<String>() { |
721 |
+ |
public String call() { |
722 |
+ |
// The delay gives the pool a chance to notice |
723 |
+ |
// the null element. |
724 |
+ |
sleepTillInterrupted(SMALL_DELAY_MS); |
725 |
+ |
return "foo"; |
726 |
+ |
}}); |
727 |
+ |
l.add(null); |
728 |
+ |
e.invokeAny(l); |
729 |
+ |
shouldThrow(); |
730 |
+ |
} catch (NullPointerException success) { |
731 |
+ |
} finally { |
732 |
+ |
joinPool(e); |
733 |
+ |
} |
734 |
+ |
} |
735 |
+ |
|
736 |
+ |
/** |
737 |
+ |
* invokeAny(c) throws ExecutionException if no task in c completes |
738 |
+ |
*/ |
739 |
+ |
public void testInvokeAny5() throws Throwable { |
740 |
+ |
ExecutorService e = new ForkJoinPool(1); |
741 |
+ |
try { |
742 |
+ |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
743 |
|
l.add(new NPETask()); |
744 |
|
e.invokeAny(l); |
745 |
|
shouldThrow(); |
752 |
|
/** |
753 |
|
* invokeAny(c) returns result of some task in c if at least one completes |
754 |
|
*/ |
755 |
< |
public void testInvokeAny5() throws Throwable { |
755 |
> |
public void testInvokeAny6() throws Throwable { |
756 |
|
ExecutorService e = new ForkJoinPool(1); |
757 |
|
try { |
758 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |