mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Fix NPE when locale specifies unknown country code.
This commit is contained in:
parent
fcb13ed772
commit
78e9ed2382
@ -23,6 +23,9 @@ import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class GlobalSettings {
|
||||
private static boolean useAnimations = true;
|
||||
private static Locale locale;
|
||||
@ -32,6 +35,7 @@ public class GlobalSettings {
|
||||
|
||||
static {
|
||||
locale = Locale.getDefault();
|
||||
log.info("Locale info: {}", locale);
|
||||
|
||||
// On some systems there is no country defined, in that case we use en_US
|
||||
if (locale.getCountry() == null || locale.getCountry().isEmpty())
|
||||
|
@ -277,8 +277,13 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
prefPayload.setUserLanguage(GlobalSettings.getLocale().getLanguage());
|
||||
prefPayload.setUserCountry(CountryUtil.getDefaultCountry());
|
||||
GlobalSettings.setLocale(new Locale(prefPayload.getUserLanguage(), prefPayload.getUserCountry().code));
|
||||
TradeCurrency preferredTradeCurrency = checkNotNull(CurrencyUtil.getCurrencyByCountryCode(prefPayload.getUserCountry().code),
|
||||
"preferredTradeCurrency must not be null");
|
||||
|
||||
TradeCurrency preferredTradeCurrency = CurrencyUtil.getCurrencyByCountryCode("US"); // default fallback option
|
||||
try {
|
||||
preferredTradeCurrency = CurrencyUtil.getCurrencyByCountryCode(prefPayload.getUserCountry().code);
|
||||
} catch (IllegalArgumentException ia) {
|
||||
log.warn("Could not determine currency for country {} [{}]", prefPayload.getUserCountry().code, ia.toString());
|
||||
}
|
||||
prefPayload.setPreferredTradeCurrency(preferredTradeCurrency);
|
||||
setFiatCurrencies(CurrencyUtil.getMainFiatCurrencies());
|
||||
setCryptoCurrencies(CurrencyUtil.getMainCryptoCurrencies());
|
||||
|
Loading…
Reference in New Issue
Block a user