RFR: 8361018: Re-examine buffering and encoding conversion in BufferedWriter [v5]
Shaojin Wen
swen at openjdk.org
Tue Jul 1 02:16:39 UTC 2025
On Tue, 1 Jul 2025 02:07:07 GMT, Brett Okken <duke at openjdk.org> wrote:
> > StreamEncoder has a ByteBuffer that acts as a buffer,
>
> At a fixed sized of 512 bytes which cannot be affected by size passed into the BufferedWriter?
So I added this method StreamEncoder::growByteBufferIfEmptyNeeded and called it in the BufferedWriter constructor
private BufferedWriter(Writer out, int initialSize, int maxSize) {
// ...
if (out instanceof OutputStreamWriter w && w.se.getCharset() == UTF_8.INSTANCE) {
w.se.growByteBufferIfEmptyNeeded(initialSize);
this.impl = new OutputStreamWriterImpl(w);
}
// ...
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26022#issuecomment-3021479496
More information about the nio-dev
mailing list