]> granicus.if.org Git - icu/commitdiff
ICU-8854 equals() does not check for null.
authorAbhinav Gupta <mail@abhinavg.net>
Mon, 24 Oct 2011 19:23:44 +0000 (19:23 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Mon, 24 Oct 2011 19:23:44 +0000 (19:23 +0000)
X-SVN-Rev: 30859

icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java
icu4j/main/classes/core/src/com/ibm/icu/text/NFSubstitution.java
icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java
icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java
icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
icu4j/main/classes/core/src/com/ibm/icu/util/CaseInsensitiveString.java
icu4j/main/classes/core/src/com/ibm/icu/util/LocalePriorityList.java
icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java

index 4c9bf5bca21c5ea048915906058bd9ff62242492..20b1a7fa81c6f025a1d6373744bba91992e44882 100644 (file)
@@ -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<C0, C1, C2, C3, C4> implements java.lang.Comparable, Cloneable,
     }
 
     public boolean equals(Object other) {
+        if (other == null) {
+            return false;
+        }
+        if (this == other) {
+            return true;
+        }
         try {
             Row<C0, C1, C2, C3, C4> that = (Row<C0, C1, C2, C3, C4>)other;
             if (items.length != that.items.length) {
index e9628e1101d0d438c56996bbb47098ea11745dd8..311cb85a0995f7c00159939c2778924df36f9fb8 100644 (file)
@@ -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;
 
index 24c7ba261abeb04dd6ea9d8db916a65521d42b54..126efc5e34214bfd7ee14dbfda11e49129325d2a 100644 (file)
@@ -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");
index 9866edb5d1d300d414502508941ba6f56e05ce1d..486e05a71d75018a664f10379b92ffc07173c471 100644 (file)
@@ -2258,6 +2258,12 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, 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;
index 211ab7cb56f732aa2857b1e90160c1d33a5a2c20..c627da66970a1191c7cc9023e2e8a29ca0c2f4a9 100644 (file)
@@ -2222,6 +2222,9 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
      * @stable ICU 2.0
      */
     public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
         if (this == obj) {
             return true;
         }
index a0818da53b4990b350d09b89e5354d699717cf2f..3fad5d97df4c043bf994ff0e69f9f87f1b649969 100644 (file)
@@ -1,6 +1,6 @@
 /**
  *******************************************************************************
- * Copyright (C) 2001-2007, International Business Machines Corporation and    *
+ * Copyright (C) 2001-2011, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -56,8 +56,13 @@ public class CaseInsensitiveString {
      * @stable ICU 2.0
      */
     public boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (this == o) {
+            return true;
+        }
         getFolded();
-        
         try {
             CaseInsensitiveString cis = (CaseInsensitiveString) o;
             
index d182b3308e15cdaee191bd86b0db1379facf2e1a..e70378d75592a39fe79e4702fc2be98a59f60fac 100644 (file)
@@ -166,6 +166,12 @@ public class LocalePriorityList implements Iterable<ULocale> {
      */
     @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);
index 041f003c084ffa261c3585623b15f46be9faed32..a911cd3a84187c3dbd07700beac0d742eb59f1be 100644 (file)
@@ -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;
             }