On Sat, 8 Aug 2026 16:41:50 GMT, Alan Bateman <[email protected]> wrote:
>> Markus KARG has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Fixed changes requested by Alan Bateman > > src/java.base/share/classes/sun/nio/cs/StreamDecoder.java line 52: > >> 50: private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192; >> 51: >> 52: private volatile boolean havePulledFromInputStream; > > If this patch goes ahead then we'll need a better name for this. But first, > why it is volatile. The reason that closed is volatile is because of async > close. I have now renamed it to `decoderContainsBytes`. It is `volatile` because `read0` is `synchronized` (which tells me that it is intended to be called by concurrent threads), so I want to take care that setting the flag in `read0` by thread A and reading the flag in `readAllAsString` by thread B will not interfere. > src/java.base/share/classes/sun/nio/cs/StreamDecoder.java line 211: > >> 209: >> 210: if (!havePulledFromInputStream) >> 211: return new String(remaining, cs); > > This assumes the CharsetDecoder is configured to use REPLACE. You'll see to > look at the uses of StreamDecoder where it may be created with a > CharsetDecoder configured otherwise (e.g. InputStreamReader constructor that > is created with a CharsetDecoder). I have now added a check that will execute the fast-path optimization only in the REPLACE case, and only with the very same charset decoder class. > src/java.base/share/classes/sun/nio/cs/StreamDecoder.java line 213: > >> 211: return new String(remaining, cs); >> 212: >> 213: int estimateSize = (haveLeftoverChar ? 1 : 0) + (int) >> Math.ceil((bb.remaining() + remaining.length) * decoder.maxCharsPerByte()); > > You can reformat this to be more consistent with the existing code. Done. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32264#discussion_r3789100764 PR Review Comment: https://git.openjdk.org/jdk/pull/32264#discussion_r3789102921 PR Review Comment: https://git.openjdk.org/jdk/pull/32264#discussion_r3789103159
