On Fri, 3 Sep 2021 13:22:54 GMT, Сергей Цыпанов <github.com+10835776+stsypa...@openjdk.org> wrote:
> Current implementation looks like this: > > public byte[] getBytes(String charsetName) > throws UnsupportedEncodingException { > if (charsetName == null) throw new NullPointerException(); > return encode(lookupCharset(charsetName), coder(), value); > } > > Null check seems to be redundant here because the same check of `charsetName` > is done within `String.lookupCharset(String)`: > > private static Charset lookupCharset(String csn) throws > UnsupportedEncodingException { > Objects.requireNonNull(csn); > try { > return Charset.forName(csn); > } catch (UnsupportedCharsetException | IllegalCharsetNameException x) { > throw new UnsupportedEncodingException(csn); > } > } This pull request has now been integrated. Changeset: e5f298a7 Author: Sergey Tsypanov <sergei.tsypa...@yandex.ru> Committer: Naoto Sato <na...@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/e5f298a7f1f3106b72e43c152c090af1657485f0 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod 8273329: Remove redundant null check from String.getBytes(String charsetName) Reviewed-by: rriggs, iris, naoto ------------- PR: https://git.openjdk.java.net/jdk/pull/5361