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

This commit is contained in:
Benedikt Ritter 2015-05-05 19:17:40 +02:00
parent e2ec4f2fdb
commit fc73151cfc
3 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,7 @@
<body> <body>
<release version="3.5" date="tba" description="tba"> <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-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-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> <action issue="LANG-1127" type="add" dev="chas">Unit test helpers which set and reset default Locale and TimeZone</action>

View File

@ -2819,6 +2819,9 @@ public boolean equals(final StrBuilder other) {
if (this == other) { if (this == other) {
return true; return true;
} }
if (other == null) {
return false;
}
if (this.size != other.size) { if (this.size != other.size) {
return false; return false;
} }

View File

@ -1850,6 +1850,13 @@ public void testEquals() {
assertFalse(sb1.equals("abc")); 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 @Test
public void testHashCode() { public void testHashCode() {