11 |
|
import java.security.PrivilegedExceptionAction; |
12 |
|
import java.util.ArrayList; |
13 |
|
import java.util.Collection; |
14 |
+ |
import java.util.Collections; |
15 |
|
import java.util.List; |
16 |
|
import java.util.concurrent.Callable; |
17 |
|
import java.util.concurrent.CountDownLatch; |
704 |
|
} |
705 |
|
|
706 |
|
/** |
707 |
< |
* invokeAll(empty collection) returns empty collection |
707 |
> |
* invokeAll(empty collection) returns empty list |
708 |
|
*/ |
709 |
|
public void testInvokeAll2() throws InterruptedException { |
710 |
|
ExecutorService e = new ForkJoinPool(1); |
711 |
+ |
final Collection<Callable<String>> emptyCollection |
712 |
+ |
= Collections.emptyList(); |
713 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
714 |
< |
List<Future<String>> r |
712 |
< |
= e.invokeAll(new ArrayList<Callable<String>>()); |
714 |
> |
List<Future<String>> r = e.invokeAll(emptyCollection); |
715 |
|
assertTrue(r.isEmpty()); |
716 |
|
} |
717 |
|
} |
821 |
|
l.add(latchAwaitingStringTask(latch)); |
822 |
|
l.add(null); |
823 |
|
try { |
824 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
824 |
> |
e.invokeAny(l, randomTimeout(), randomTimeUnit()); |
825 |
|
shouldThrow(); |
826 |
|
} catch (NullPointerException success) {} |
827 |
|
latch.countDown(); |
870 |
|
ExecutorService e = new ForkJoinPool(1); |
871 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
872 |
|
try { |
873 |
< |
e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); |
873 |
> |
e.invokeAll(null, randomTimeout(), randomTimeUnit()); |
874 |
|
shouldThrow(); |
875 |
|
} catch (NullPointerException success) {} |
876 |
|
} |
885 |
|
List<Callable<String>> l = new ArrayList<>(); |
886 |
|
l.add(new StringTask()); |
887 |
|
try { |
888 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
888 |
> |
e.invokeAll(l, randomTimeout(), null); |
889 |
|
shouldThrow(); |
890 |
|
} catch (NullPointerException success) {} |
891 |
|
} |
892 |
|
} |
893 |
|
|
894 |
|
/** |
895 |
< |
* timed invokeAll(empty collection) returns empty collection |
895 |
> |
* timed invokeAll(empty collection) returns empty list |
896 |
|
*/ |
897 |
|
public void testTimedInvokeAll2() throws InterruptedException { |
898 |
|
ExecutorService e = new ForkJoinPool(1); |
899 |
+ |
final Collection<Callable<String>> emptyCollection |
900 |
+ |
= Collections.emptyList(); |
901 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
902 |
|
List<Future<String>> r |
903 |
< |
= e.invokeAll(new ArrayList<Callable<String>>(), |
904 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
903 |
> |
= e.invokeAll(emptyCollection, |
904 |
> |
randomTimeout(), randomTimeUnit()); |
905 |
|
assertTrue(r.isEmpty()); |
906 |
|
} |
907 |
|
} |
916 |
|
l.add(new StringTask()); |
917 |
|
l.add(null); |
918 |
|
try { |
919 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
919 |
> |
e.invokeAll(l, randomTimeout(), randomTimeUnit()); |
920 |
|
shouldThrow(); |
921 |
|
} catch (NullPointerException success) {} |
922 |
|
} |