Merge branch 'pr-340'

This closes #340
This commit is contained in:
Bruno P. Kinoshita 2022-10-19 15:09:53 +13:00
commit 304a1bf3f3
3 changed files with 12 additions and 1 deletions

View File

@ -98,7 +98,10 @@
Fix flaky EmptyPropertiesTest#testSave.
</action>
<action type="fix" dev="ggregory" due-to="Steve Bosman">
Use java.lang.Objects#equals; eliminate a couple of nulls #307
Use java.lang.Objects#equals; eliminate a couple of nulls #307.
</action>
<action issue="COLLECTIONS-814" type="fix" dev="kinow" due-to="angusdev">
CollectionUtils.removeAll() not throwing NPE #340.
</action>
<!-- ADD -->
<action issue="COLLECTIONS-760" dev="kinow" type="add" due-to="Isira Seneviratne">

View File

@ -533,6 +533,8 @@ public class ListUtils {
* @since 3.2
*/
public static <E> List<E> removeAll(final Collection<E> collection, final Collection<?> remove) {
Objects.requireNonNull(collection, "collection");
Objects.requireNonNull(remove, "remove");
final List<E> list = new ArrayList<>();
for (final E obj : collection) {
if (!remove.contains(obj)) {

View File

@ -369,6 +369,12 @@ public class ListUtilsTest {
assertThrows(NullPointerException.class, () -> ListUtils.removeAll(null, null),
"expecting NullPointerException");
assertThrows(NullPointerException.class, () -> ListUtils.removeAll(null, new ArrayList<Object>()),
"expecting NullPointerException");
assertThrows(NullPointerException.class, () -> ListUtils.removeAll(new ArrayList<Object>(), null),
"expecting NullPointerException");
}
@Test