commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1361462 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/StringUtils.java test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
Date Sat, 14 Jul 2012 00:53:37 GMT
Author: sebb
Date: Sat Jul 14 00:53:36 2012
New Revision: 1361462

URL: http://svn.apache.org/viewvc?rev=1361462&view=rev
Log:
LANG-813 StringUtils.equalsIgnoreCase doesn't check string reference equality
Also check lengths.

Modified:
    commons/proper/lang/trunk/src/changes/changes.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1361462&r1=1361461&r2=1361462&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Sat Jul 14 00:53:36 2012
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.2" date="TBA" description="Next release">
+    <action issue="LANG-813" type="fix">StringUtils.equalsIgnoreCase doesn't check
string reference equality</action>
     <action issue="LANG-807" type="fix">RandomStringUtils throws confusing IAE when
end &lt;= start</action>
     <action issue="LANG-805" type="fix">RandomStringUtils.random(count, 0, 0, false,
false, universe, random) always throws java.lang.ArrayIndexOutOfBoundsException</action>
     <action issue="LANG-802" type="fix">LocaleUtils - unnecessary recursive call in
SyncAvoid class.</action>

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1361462&r1=1361461&r2=1361462&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Sat
Jul 14 00:53:36 2012
@@ -691,8 +691,12 @@ public class StringUtils {
     public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2) {
         if (str1 == null || str2 == null) {
             return str1 == str2;
+        } else if (str1 == str2) {
+            return true;
+        } else if (str1.length() != str2.length()) {
+            return false;
         } else {
-            return CharSequenceUtils.regionMatches(str1, true, 0, str2, 0, Math.max(str1.length(),
str2.length()));
+            return CharSequenceUtils.regionMatches(str1, true, 0, str2, 0, str1.length());
         }
     }
 

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java?rev=1361462&r1=1361461&r2=1361462&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
Sat Jul 14 00:53:36 2012
@@ -525,6 +525,8 @@ public class StringUtilsEqualsIndexOfTes
         assertEquals(false, StringUtils.equalsIgnoreCase(FOO, BAR));
         assertEquals(false, StringUtils.equalsIgnoreCase(FOO, null));
         assertEquals(false, StringUtils.equalsIgnoreCase(null, FOO));
+        assertEquals(true, StringUtils.equalsIgnoreCase("",""));
+        assertEquals(false, StringUtils.equalsIgnoreCase("abcd","abcd "));
     }
 
     //-----------------------------------------------------------------------



Mime
View raw message