RFR: 8351000: StringBuilder getChar and putChar robustness

Andrey Turbanov aturbanov at openjdk.org
Wed Apr 30 08:02:50 UTC 2025


On Tue, 29 Apr 2025 14:10:30 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Improve StringBuilder getChar and putChar robustness with racy updates to StringBuilder. 
> Test racing threads with append, insert, and reading characters.

test/jdk/java/lang/StringBuilder/RacingSBThreads.java line 61:

> 59:     // Constant arguments available to be passed to StringBuilder operations
> 60:     private static final StringBuilder otherSB = new StringBuilder("ab\uFF21\uFF22");
> 61:     private static final CharBuffer otherCharBuffer = CharBuffer.allocate(4).append("a\uFF21");

unused field

test/jdk/java/lang/StringBuilder/RacingSBThreads.java line 85:

> 83:      * Run the stress cases indicated by command line arguments or run all cases.
> 84:      * Running each for TIMEOUT_SEC seconds or until a failure.
> 85:      * The timeuut/test duration can be scaled by setting System property

Suggestion:

     * The timeout/test duration can be scaled by setting System property

test/jdk/java/lang/StringBuilder/RacingSBThreads.java line 158:

> 156:             this.func = func;
> 157:             this.sbInitString = sbInitString;
> 158:         };

Suggestion:

        }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24951#discussion_r2068110759
PR Review Comment: https://git.openjdk.org/jdk/pull/24951#discussion_r2068109643
PR Review Comment: https://git.openjdk.org/jdk/pull/24951#discussion_r2068110062


More information about the core-libs-dev mailing list