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); } } ------------- Commit messages: - 8273329: Remove redundant null check from String.getBytes(String charsetName) Changes: https://git.openjdk.java.net/jdk/pull/5361/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5361&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8273329 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/5361.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5361/head:pull/5361 PR: https://git.openjdk.java.net/jdk/pull/5361