-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b93
-
Verified
sb1.append("TEST").append((CharSequence)null) , this works as expected.
But if the second append is called after toString(), "null" is then not appended.
public class TestAppendNull {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer();
sb1.append("TEST");
System.out.println(sb1.toString());
sb1.append((CharSequence)null);
System.out.println("Expected: TESTnull");
System.out.println("Result: " + sb1.toString());
}
}
bash-3.2$ $JAVA_HOME/bin/java TestAppendNull
TEST
Expected: TESTnull
Result: TEST
SQE test
java_lang/Bug4812591
failed due to this issue
But if the second append is called after toString(), "null" is then not appended.
public class TestAppendNull {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer();
sb1.append("TEST");
System.out.println(sb1.toString());
sb1.append((CharSequence)null);
System.out.println("Expected: TESTnull");
System.out.println("Result: " + sb1.toString());
}
}
bash-3.2$ $JAVA_HOME/bin/java TestAppendNull
TEST
Expected: TESTnull
Result: TEST
SQE test
java_lang/Bug4812591
failed due to this issue
- relates to
-
JDK-8013395 StringBuffer.toString performance regression impacting embedded benchmarks
- Resolved
-
JDK-8010849 (str) Optimize StringBuilder.append(null)
- Closed