RFR: 8357681: Fixed the DigitList::toString method causing incorrect results during debugging

Shaojin Wen swen at openjdk.org
Tue May 27 19:47:54 UTC 2025


On Tue, 27 May 2025 19:31:44 GMT, Volkan Yazici <vyazici at openjdk.org> 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


More information about the core-libs-dev mailing list