commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [lang] LANG-1131: StrBuilder.equals(StrBuilder) doesn't check for null inputs
Date Tue, 05 May 2015 17:18:09 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master e2ec4f2fd -> fc73151cf


LANG-1131: StrBuilder.equals(StrBuilder) doesn't check for null inputs


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/fc73151c
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/fc73151c
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/fc73151c

Branch: refs/heads/master
Commit: fc73151cfca36ea2641f340700dbe339b9e1f103
Parents: e2ec4f2
Author: Benedikt Ritter <britter@apache.org>
Authored: Tue May 5 19:17:40 2015 +0200
Committer: Benedikt Ritter <britter@apache.org>
Committed: Tue May 5 19:17:40 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                       | 1 +
 src/main/java/org/apache/commons/lang3/text/StrBuilder.java   | 3 +++
 .../java/org/apache/commons/lang3/text/StrBuilderTest.java    | 7 +++++++
 3 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fc73151c/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f151745..2081591 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1131" type="fix" dev="britter">StrBuilder.equals(StrBuilder)
doesn't check for null inputs</action>
     <action issue="LANG-1105" type="add" dev="britter" due-to="Hendrik Saly">Add ThreadUtils
- A utility class which provides helper methods related to java.lang.Thread</action>
     <action issue="LANG-1031" type="add" dev="britter" due-to="Felipe Adorno">Add annotations
to exclude fields from ReflectionEqualsBuilder, ReflectionToStringBuilder and ReflectionHashCodeBuilder</action>
     <action issue="LANG-1127" type="add" dev="chas">Unit test helpers which set and
reset default Locale and TimeZone</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fc73151c/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
index 26b475f..7b541a6 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
@@ -2819,6 +2819,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable,
Build
         if (this == other) {
             return true;
         }
+        if (other == null) {
+            return false;
+        }
         if (this.size != other.size) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fc73151c/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
index 2da4cf1..a9c6145 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
@@ -1850,6 +1850,13 @@ public class StrBuilderTest {
         assertFalse(sb1.equals("abc"));
     }
 
+    @Test
+    public void test_LANG_1131_EqualsWithNullStrBuilder() throws Exception {
+        final StrBuilder sb = new StrBuilder();
+        final StrBuilder other = null;
+        assertFalse(sb.equals(other));
+    }
+
     //-----------------------------------------------------------------------
     @Test
     public void testHashCode() {


Mime
View raw message