On Tue, 27 May 2025 19:31:44 GMT, Volkan Yazici <[email protected]> wrote:
> _Nit:_ Would it be an overkill to add a test (verifying `toString` doesn't
> spoil the content) to avoid falling on the same slippery slope (i.e., _"Let
> me optimize this by reusing the `SB`!"_) again?
The original code that calls getStringBuilder() is this code:
private StringBuilder tempBuilder;
private StringBuilder getStringBuilder() {
if (tempBuilder == null) {
tempBuilder = new StringBuilder(MAX_COUNT);
} else {
tempBuilder.setLength(0);
}
return tempBuilder;
}
This is a concurrency problem, which is triggered during the DEBUG process.
To test this concurrency problem, we need to build a concurrent competition
test, which is not a simple task, so I did not add it.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25288#issuecomment-2913802759