Open jaredfishy opened 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)
Trying to retrieve the Currency object for MRU throws a NullPointerException.
Code to recreate issue:
Currency currency = CurrencyCode.MRU.getCurrency();