10 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
11 |
|
|
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.ArrayBlockingQueue; |
17 |
|
import java.util.concurrent.BlockingQueue; |
1466 |
|
} |
1467 |
|
|
1468 |
|
/** |
1469 |
< |
* invokeAny(null) throws NPE |
1469 |
> |
* invokeAny(null) throws NullPointerException |
1470 |
|
*/ |
1471 |
|
public void testInvokeAny1() throws Exception { |
1472 |
|
final ExecutorService e = |
1482 |
|
} |
1483 |
|
|
1484 |
|
/** |
1485 |
< |
* invokeAny(empty collection) throws IAE |
1485 |
> |
* invokeAny(empty collection) throws IllegalArgumentException |
1486 |
|
*/ |
1487 |
|
public void testInvokeAny2() throws Exception { |
1488 |
|
final ExecutorService e = |
1572 |
|
} |
1573 |
|
|
1574 |
|
/** |
1575 |
< |
* invokeAll(empty collection) returns empty collection |
1575 |
> |
* invokeAll(empty collection) returns empty list |
1576 |
|
*/ |
1577 |
|
public void testInvokeAll2() throws Exception { |
1578 |
|
final ExecutorService e = |
1579 |
|
new CustomTPE(2, 2, |
1580 |
|
LONG_DELAY_MS, MILLISECONDS, |
1581 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1582 |
+ |
final Collection<Callable<String>> emptyCollection |
1583 |
+ |
= Collections.emptyList(); |
1584 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1585 |
< |
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>()); |
1585 |
> |
List<Future<String>> r = e.invokeAll(emptyCollection); |
1586 |
|
assertTrue(r.isEmpty()); |
1587 |
|
} |
1588 |
|
} |
1657 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1658 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1659 |
|
try { |
1660 |
< |
e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); |
1660 |
> |
e.invokeAny(null, randomTimeout(), randomTimeUnit()); |
1661 |
|
shouldThrow(); |
1662 |
|
} catch (NullPointerException success) {} |
1663 |
|
} |
1675 |
|
List<Callable<String>> l = new ArrayList<>(); |
1676 |
|
l.add(new StringTask()); |
1677 |
|
try { |
1678 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
1678 |
> |
e.invokeAny(l, randomTimeout(), null); |
1679 |
|
shouldThrow(); |
1680 |
|
} catch (NullPointerException success) {} |
1681 |
|
} |
1682 |
|
} |
1683 |
|
|
1684 |
|
/** |
1685 |
< |
* timed invokeAny(empty collection) throws IAE |
1685 |
> |
* timed invokeAny(empty collection) throws IllegalArgumentException |
1686 |
|
*/ |
1687 |
|
public void testTimedInvokeAny2() throws Exception { |
1688 |
|
final ExecutorService e = |
1689 |
|
new CustomTPE(2, 2, |
1690 |
|
LONG_DELAY_MS, MILLISECONDS, |
1691 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1692 |
+ |
final Collection<Callable<String>> emptyCollection |
1693 |
+ |
= Collections.emptyList(); |
1694 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1695 |
|
try { |
1696 |
< |
e.invokeAny(new ArrayList<Callable<String>>(), |
1691 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
1696 |
> |
e.invokeAny(emptyCollection, randomTimeout(), randomTimeUnit()); |
1697 |
|
shouldThrow(); |
1698 |
|
} catch (IllegalArgumentException success) {} |
1699 |
|
} |
1713 |
|
l.add(latchAwaitingStringTask(latch)); |
1714 |
|
l.add(null); |
1715 |
|
try { |
1716 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1716 |
> |
e.invokeAny(l, randomTimeout(), MILLISECONDS); |
1717 |
|
shouldThrow(); |
1718 |
|
} catch (NullPointerException success) {} |
1719 |
|
latch.countDown(); |
1771 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1772 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1773 |
|
try { |
1774 |
< |
e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); |
1774 |
> |
e.invokeAll(null, randomTimeout(), randomTimeUnit()); |
1775 |
|
shouldThrow(); |
1776 |
|
} catch (NullPointerException success) {} |
1777 |
|
} |
1789 |
|
List<Callable<String>> l = new ArrayList<>(); |
1790 |
|
l.add(new StringTask()); |
1791 |
|
try { |
1792 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
1792 |
> |
e.invokeAll(l, randomTimeout(), null); |
1793 |
|
shouldThrow(); |
1794 |
|
} catch (NullPointerException success) {} |
1795 |
|
} |
1796 |
|
} |
1797 |
|
|
1798 |
|
/** |
1799 |
< |
* timed invokeAll(empty collection) returns empty collection |
1799 |
> |
* timed invokeAll(empty collection) returns empty list |
1800 |
|
*/ |
1801 |
|
public void testTimedInvokeAll2() throws Exception { |
1802 |
|
final ExecutorService e = |
1803 |
|
new CustomTPE(2, 2, |
1804 |
|
LONG_DELAY_MS, MILLISECONDS, |
1805 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1806 |
+ |
final Collection<Callable<String>> emptyCollection |
1807 |
+ |
= Collections.emptyList(); |
1808 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1809 |
< |
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), |
1810 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
1809 |
> |
List<Future<String>> r = |
1810 |
> |
e.invokeAll(emptyCollection, randomTimeout(), randomTimeUnit()); |
1811 |
|
assertTrue(r.isEmpty()); |
1812 |
|
} |
1813 |
|
} |
1825 |
|
l.add(new StringTask()); |
1826 |
|
l.add(null); |
1827 |
|
try { |
1828 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1828 |
> |
e.invokeAll(l, randomTimeout(), randomTimeUnit()); |
1829 |
|
shouldThrow(); |
1830 |
|
} catch (NullPointerException success) {} |
1831 |
|
} |