LocaleUtils: don't NPE if no default locale mapping exists (#1239)

This commit is contained in:
Camotoy 2020-09-01 18:29:53 -04:00 committed by GitHub
parent b5f6ada4ae
commit 7c4868cada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -246,6 +246,11 @@ public class LocaleUtils {
Map<String, String> localeStrings = LocaleUtils.LOCALE_MAPPINGS.get(locale.toLowerCase()); Map<String, String> localeStrings = LocaleUtils.LOCALE_MAPPINGS.get(locale.toLowerCase());
if (localeStrings == null) if (localeStrings == null)
localeStrings = LocaleUtils.LOCALE_MAPPINGS.get(LanguageUtils.getDefaultLocale()); localeStrings = LocaleUtils.LOCALE_MAPPINGS.get(LanguageUtils.getDefaultLocale());
if (localeStrings == null) {
// Don't cause a NPE if the locale is STILL missing
GeyserConnector.getInstance().getLogger().debug("MISSING DEFAULT LOCALE: " + LanguageUtils.getDefaultLocale());
return messageText;
}
return localeStrings.getOrDefault(messageText, messageText); return localeStrings.getOrDefault(messageText, messageText);
} }