JavaMoney / jsr354-ri

JSR 354 - Moneta: Reference Implementation
Other
344 stars 101 forks source link

NullPointerException on getProviderName() when a valid provider exists #242

Closed manmedia closed 5 years ago

manmedia commented 6 years ago

The following code generates a query successfully

CurrencyQuery query = CurrencyQueryBuilder.of().setProviderName("ProviderClassName").setCurrencyCodes("CNH").build();

But when the appropriate CurrencyProvider imp is loaded and getCurrencies(CurrencyQuery) is invoked, the following code results into NPE.

if (!query.isEmpty() && query.getProviderName().equals("SomeName")) {

      for (CurrencyUnit c : currencySet) {

          if (c.getCurrencyCodes().equals(query.getCurrencyCodes()) {

             return Collections.singleton(c);

          }

     }

}

We are always building the currency query such that it will have a provider name and currency unit. The above code results into an NPE for getProviderName() where a provider name actually exists.

keilw commented 6 years ago

This looks like a duplicate of https://github.com/JavaMoney/jsr354-api/issues/100.

keilw commented 5 years ago

Closing here because it was already raised in the API