TakahikoKawasaki / nv-i18n

Package to support internationalization, containing ISO 3166-1 country code enum, ISO 639-1 language code enum, etc.
Apache License 2.0
389 stars 115 forks source link

NullPointerException when getting Currency for CurrencyCode.MRU. #63

Open jaredfishy opened 4 years ago

jaredfishy commented 4 years ago

Trying to retrieve the Currency object for MRU throws a NullPointerException.

Code to recreate issue:

Currency currency = CurrencyCode.MRU.getCurrency();

TakahikoKawasaki commented 4 years ago

Currency.getCurrency() is a wrapper for java.util.Currency.getInstance(String). If the getInstance(String) returns null or throws an IllegalArgumentException, Currency.getCurrency() returns null.

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
$ cat TestMRUCurrency.java 
public class TestMRUCurrency
{
    public static void main(String[] args)
    {
        System.out.println(java.util.Currency.getInstance("MRU"));
    }
}
$ java TestMRUCurrency
Exception in thread "main" java.lang.IllegalArgumentException
    at java.util.Currency.getInstance(Currency.java:345)
    at java.util.Currency.getInstance(Currency.java:310)
    at TestMRUCurrency.main(TestMRUCurrency.java:5)