Appending a null Object/String to InternalStringBuilder is now a no-op, previously appended "null"

This commit is contained in:
Travis Burtrum 2019-01-08 15:39:00 -05:00
parent ae29ec9928
commit 4246a0cc40

View File

@ -45,7 +45,7 @@ public final class InternalStringBuilder
public InternalStringBuilder( String str ) public InternalStringBuilder( String str )
{ {
this( str.length() + 16 ); this( (str == null ? 0 : str.length()) + 16 );
append( str ); append( str );
} }
@ -98,12 +98,13 @@ public final class InternalStringBuilder
public InternalStringBuilder append( Object obj ) public InternalStringBuilder append( Object obj )
{ {
if ( obj == null ) return this; // this used to append "null"
return append( String.valueOf( obj ) ); return append( String.valueOf( obj ) );
} }
public InternalStringBuilder append( String str ) public InternalStringBuilder append( String str )
{ {
if ( str == null ) str = String.valueOf( str ); if ( str == null ) return this; // this used to append "null" like: str = String.valueOf( str );
int len = str.length(); int len = str.length();
ensureCapacity( _length + len ); ensureCapacity( _length + len );
str.getChars( 0, len, _buffer, _length ); str.getChars( 0, len, _buffer, _length );