On Thu, 27 Aug 2026 17:09:23 GMT, Jaikiran Pai <[email protected]> wrote:

>> Markus KARG has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Simplified approach by Alan Bateman
>
> src/java.base/share/classes/sun/nio/cs/StreamDecoder.java line 397:
> 
>> 395:         synchronized (lock) {
>> 396:             ensureOpen();
>> 397:             if (in != null && decoderFromCharset && !readCalled) {
> 
> As far as I can see, the `readBytes()` method, which is where the 
> `readCalled` gets set, gets called only when holding the monitor on `lock`. 
> Here too in `tryReadAllAsString()` we synchronize on `lock`, so the 
> `volatile` on `readCalled` isn't necessary.

The clearest place to set readCalled is as close as possible to where read is 
called, so read and read0 after acquiring lock.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32264#discussion_r3874070167

Reply via email to