diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 5bab383dfa..7f047e796e 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -503,12 +503,21 @@ public static boolean isProperSubCollection(final Collection> a, final Collect * That is, iff the cardinality of e in a is * equal to the cardinality of e in b, * for each element e in a or b. + *
+ * {@code null}s are handled without exceptions. Two {@code null}
+ * references are considered to be equal.
*
* @param a the first collection, must not be null
* @param b the second collection, must not be null
* @return true iff the collections contain the same elements with the same cardinalities.
*/
public static boolean isEqualCollection(final Collection> a, final Collection> b) {
+ if(a == null && b == null) {
+ return true;
+ }
+ if(a == null || b == null) {
+ return false;
+ }
if(a.size() != b.size()) {
return false;
}
@@ -532,6 +541,9 @@ public static boolean isEqualCollection(final Collection> a, final Collection<
* equal to the cardinality of e in b,
* for each element e in a or b.
*
+ * {@code null}s are handled without exceptions. Two {@code null} + * references are considered to be equal. + *
* Note: from version 4.1 onwards this method requires the input
* collections and equator to be of compatible type (using bounded wildcards).
* Providing incompatible arguments (e.g. by casting to their rawtypes)
@@ -552,10 +564,6 @@ public static