8270490: Charset.forName() taking fallback default value

Reviewed-by: joehw, rriggs, serb, dfuchs
This commit is contained in:
Naoto Sato 2021-10-27 12:39:46 +00:00
parent a29273336b
commit 168081efc8
3 changed files with 109 additions and 8 deletions

View file

@ -582,17 +582,12 @@ public final class Console implements Flushable
csname = GetPropertyAction.privilegedGetProperty("sun.stdout.encoding");
}
if (csname != null) {
try {
cs = Charset.forName(csname);
} catch (Exception ignored) { }
cs = Charset.forName(csname, null);
}
}
if (cs == null) {
try {
cs = Charset.forName(StaticProperty.nativeEncoding());
} catch (Exception ignored) {
cs = Charset.defaultCharset();
}
cs = Charset.forName(StaticProperty.nativeEncoding(),
Charset.defaultCharset());
}
CHARSET = cs;