Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.4
-
None
-
None
Description
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:
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 } } }
The last Equator parameter is null and a NPE should be thrown, however the method executes normally, and test case fails.