[COLLECTIONS-400] Added missing null check, thanks to Shin Hwei Tan.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1311344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2012-04-09 17:27:15 +00:00
parent 68673c6c52
commit b9b6f31089
1 changed files with 3 additions and 0 deletions

View File

@ -782,6 +782,9 @@ public class CollectionUtils {
* @since Commons Collections 3.2
*/
public static <T> boolean addIgnoreNull(Collection<T> collection, T object) {
if (collection == null) {
throw new NullPointerException("The collection must not be null");
}
return (object != null && collection.add(object));
}