-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b14
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 fo '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);
}
}
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 fo '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);
}
}