mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8322512: StringBuffer.repeat does not work correctly after toString() was called
Reviewed-by: rriggs, jpai
This commit is contained in:
parent
c3cd1f1814
commit
df22fb322e
2 changed files with 16 additions and 1 deletions
|
@ -715,6 +715,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
|
|||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer repeat(int codePoint, int count) {
|
||||
toStringCache = null;
|
||||
super.repeat(codePoint, count);
|
||||
return this;
|
||||
}
|
||||
|
@ -726,6 +727,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
|
|||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer repeat(CharSequence cs, int count) {
|
||||
toStringCache = null;
|
||||
super.repeat(cs, count);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Arrays;
|
|||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8302323
|
||||
* @bug 8302323 8322512
|
||||
* @summary Test StringBuffer.repeat sanity tests
|
||||
* @run testng/othervm -XX:-CompactStrings StringBufferRepeat
|
||||
* @run testng/othervm -XX:+CompactStrings StringBufferRepeat
|
||||
|
@ -129,6 +129,19 @@ public class StringBufferRepeat {
|
|||
expected = "\u0000\u0000\u0000\u0000\u0000\u0000\u0020\u0020\u0020\u0020\u0020\u0020\u2461\u2462\u2462\u2462\u2462\u2462\udbff\udfff\udbff\udfff\udbff\udfff\udbff\udfff\udbff\udfff\udbff\udfff";
|
||||
assertEquals(expected, sb.toString());
|
||||
|
||||
// toStringCache
|
||||
|
||||
sb.setLength(0);
|
||||
sb.toString();
|
||||
sb.repeat('*', 5);
|
||||
expected = "*****";
|
||||
assertEquals(sb.toString(), expected);
|
||||
sb.setLength(0);
|
||||
sb.toString();
|
||||
sb.repeat("*", 5);
|
||||
assertEquals(sb.toString(), expected);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void exceptions() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue