On Tue, 25 Aug 2026 17:46:19 GMT, Markus KARG <[email protected]> wrote:

>> This Pull Request provides an implementation for 
>> [JDK-8389573](https://bugs.openjdk.org/browse/JDK-8389573): 
>> 'InputStreamReader.readAllAsString() should override the generic Reader 
>> default implementation to avoid unnecessary buffer copies'.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> 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.

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

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

Reply via email to