Elia Bertolina created COLLECTIONS-813:
------------------------------------------
Summary: CollectionUtils.retainAll() not throwing proper
NullPointerException(NPE)
Key: COLLECTIONS-813
URL: https://issues.apache.org/jira/browse/COLLECTIONS-813
Project: Commons Collections
Issue Type: Bug
Affects Versions: 4.4
Reporter: Elia Bertolina
The CollectionUtils.retainAll(Iterable<E> collection, Iterable<? extends E>
retain, Equator<? super E> equator) does not throw a NullPointerException(NPE)
when one of the parameters is null.In the documentation it is stated that an
NPE will be thrown if any of the parameters is null.
However, in this test case:
{code:java}
public class CollectionUtils_failure_Test {
public void test() throws Throwable {
HashSet<Integer> hashSet = new HashSet<Integer>(1095, 1095);
try {
Collection<Integer> collection =
CollectionUtils.retainAll((Iterable<Integer>) hashSet,
(Iterable<? extends Integer>) hashSet,
(Equator<? super Integer>) null);
org.junit.Assert.fail();
}
catch (java.lang.NullPointerException e) {
//NPE caught and test successful
}
}
}{code}
The last Equator parameter is null and a NPE should be thrown, however the
method executes normally, and test case fails.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)