From: Abhinav Gupta Date: Mon, 24 Oct 2011 19:23:44 +0000 (+0000) Subject: ICU-8854 equals() does not check for null. X-Git-Tag: milestone-59-0-1~4395 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f0127fd5d2c2a881f1005af0abbad2962344715;p=icu ICU-8854 equals() does not check for null. X-SVN-Rev: 30859 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java index 4c9bf5bca21..20b1a7fa81c 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (c) 2002-2010, Google, International Business Machines + * Copyright (c) 2002-2011, Google, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Mark Davis @@ -102,6 +102,12 @@ public class Row implements java.lang.Comparable, Cloneable, } public boolean equals(Object other) { + if (other == null) { + return false; + } + if (this == other) { + return true; + } try { Row that = (Row)other; if (items.length != that.items.length) { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/NFSubstitution.java b/icu4j/main/classes/core/src/com/ibm/icu/text/NFSubstitution.java index e9628e1101d..311cb85a099 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/NFSubstitution.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/NFSubstitution.java @@ -254,6 +254,12 @@ abstract class NFSubstitution { public boolean equals(Object that) { // compare class and all of the fields all substitutions have // in common + if (that == null) { + return false; + } + if (this == that) { + return true; + } if (this.getClass() == that.getClass()) { NFSubstitution that2 = (NFSubstitution)that; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java index 24c7ba261ab..126efc5e342 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java @@ -116,6 +116,12 @@ public class RuleBasedBreakIterator extends BreakIterator { * @stable ICU 2.0 */ public boolean equals(Object that) { + if (that == null) { + return false; + } + if (this == that) { + return true; + } try { RuleBasedBreakIterator other = (RuleBasedBreakIterator) that; if (fRData != other.fRData && (fRData == null || other.fRData == null)) {System.out.println("GOT HERE"); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java index 9866edb5d1d..486e05a71d7 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java @@ -2258,6 +2258,12 @@ public class UnicodeSet extends UnicodeFilter implements Iterable, Compa * @stable ICU 2.0 */ public boolean equals(Object o) { + if (o == null) { + return false; + } + if (this == o) { + return true; + } try { UnicodeSet that = (UnicodeSet) o; if (len != that.len) return false; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java index 211ab7cb56f..c627da66970 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java @@ -2222,6 +2222,9 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable { */ @Override public boolean equals(final Object o) { + if (o == null) { + return false; + } + if (this == o) { + return true; + } try { final LocalePriorityList that = (LocalePriorityList) o; return languagesAndWeights.equals(that.languagesAndWeights); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java b/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java index 041f003c084..a911cd3a841 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java @@ -389,6 +389,9 @@ public abstract class UResourceBundle extends ResourceBundle { private int hashCodeCache; ///CLOVER:OFF public boolean equals(Object other) { + if (other == null) { + return false; + } if (this == other) { return true; }