[
https://issues.apache.org/jira/browse/COLLECTIONS-813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17538712#comment-17538712
]
Alex Herbert commented on COLLECTIONS-813:
------------------------------------------
This test passes in the current master branch (4.5-SNAPSHOT).
There is a check on the {{Equator<? super E> equator}} using
{{{}Objects.requireNonNull{}}}.
This was added in commit 7eb78290c8d7d1fa379536700de0bd4a81320bb0.
See [Diff 7eb78290c8d7d1fa379536700de0bd4a81320bb0 line
1827|https://github.com/apache/commons-collections/commit/7eb78290c8d7d1fa379536700de0bd4a81320bb0#diff-894d12b57c99e81a9fa2c4aefe45d664c6009a3ff8be7767170466a25c971c44R1827]
> 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
> Priority: Major
>
> 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)