RFR: 8305902: (cs) Resolve default Charset only once in StreamEncoder and StreamDecoder

Alan Bateman alanb at openjdk.org
Wed Apr 12 11:45:30 UTC 2023


On Wed, 12 Apr 2023 11:36:54 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

> If `charsetName` passed into `forOutputStreamWriter()` method is null then `Charset.forName()` is redundant as we can use already resolved default Charset.

src/java.base/share/classes/sun/nio/cs/StreamDecoder.java line 76:

> 74:         String csn = charsetName;
> 75:         try {
> 76:             return new StreamDecoder(in, lock, csn == null ? Charset.defaultCharset() : Charset.forName(csn));

Can you check the callers, it may be that the mapping of null to the default CS can be removed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13443#discussion_r1164011178


More information about the nio-dev mailing list