From b9284992ea3c8c484893517ee9df3b2274296959 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Wed, 29 Oct 2014 21:05:03 +0000 Subject: [PATCH] [COLLECTIONS-536] Improved null check. Thanks to Tagir Valeev. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1635303 13f79535-47bb-0310-9956-ffa450edef68 --- src/changes/changes.xml | 3 +++ src/main/java/org/apache/commons/collections4/MapUtils.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 861c47e7c..e91e364c8 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,6 +22,9 @@ + + Improved check for null input in "MapUtils#putAll(Map, Object[])". + Added clarifying javadoc wrt runtime complexity of "CollectionBag#retainAll". diff --git a/src/main/java/org/apache/commons/collections4/MapUtils.java b/src/main/java/org/apache/commons/collections4/MapUtils.java index bfd03d803..c65bf089b 100644 --- a/src/main/java/org/apache/commons/collections4/MapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MapUtils.java @@ -1147,7 +1147,9 @@ public class MapUtils { */ @SuppressWarnings("unchecked") // As per Javadoc throws CCE for invalid array contents public static Map putAll(final Map map, final Object[] array) { - map.size(); // force NPE + if (map == null) { + throw new NullPointerException("The map must not be null"); + } if (array == null || array.length == 0) { return map; }