提交 eafdb3b6 编写于 作者: D dholmes

8014814: (str) StringBuffer "null" is not appended

Reviewed-by: alanb
上级 243576f5
...@@ -335,10 +335,8 @@ import java.util.Arrays; ...@@ -335,10 +335,8 @@ import java.util.Arrays;
* @since 1.5 * @since 1.5
*/ */
@Override @Override
public StringBuffer append(CharSequence s) { public synchronized StringBuffer append(CharSequence s) {
// Note, synchronization achieved via invocations of other StringBuffer methods after toStringCache = null;
// narrowing of s to specific type
// Ditto for toStringCache clearing
super.append(s); super.append(s);
return this; return this;
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 8013395 * @bug 8013395 8014814
* @summary Test StringBuffer.toString caching * @summary Test StringBuffer.toString caching
*/ */
...@@ -199,6 +199,28 @@ public class ToStringCache { ...@@ -199,6 +199,28 @@ public class ToStringCache {
b = sb.toString(); b = sb.toString();
checkUnequal(a, b); checkUnequal(a, b);
// Extra checks that append(null) works correctly
sb.append((String)null);
b = sb.toString();
checkUnequal(a, b);
a = b;
sb.append((StringBuffer)null);
b = sb.toString();
checkUnequal(a, b);
a = b;
sb.append((StringBuilder)null);
b = sb.toString();
checkUnequal(a, b);
a = b;
sb.append((CharSequence)null);
b = sb.toString();
checkUnequal(a, b);
a = b;
// non-mutating methods // non-mutating methods
// Reset to known value // Reset to known value
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册