8341366: Suspicious check in Locale.getDisplayName(Locale inLocale)

Reviewed-by: naoto
This commit is contained in:
Justin Lu 2024-10-09 21:45:47 +00:00
parent 52eded4a9c
commit 49c7148d37

View File

@ -2324,12 +2324,11 @@ public final class Locale implements Cloneable, Serializable {
// If we cannot get the message format pattern, then we use a simple
// hard-coded pattern. This should not occur in practice unless the
// installation is missing some core files (FormatData etc.).
StringBuilder result = new StringBuilder();
result.append((String)displayNames[1]);
if (displayNames.length > 2) {
result.append(" (");
result.append((String)displayNames[2]);
result.append(')');
StringBuilder result = new StringBuilder((String) displayNames[1]);
if (displayNames[2] != null) {
result.append(" (")
.append((String) displayNames[2])
.append(')');
}
return result.toString();
}