You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullPointerException on getProviderName() even when provider name exists #100
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.
Was it possible to debug the code to see, which line throws the NPE?
In the first one swapping the equals() method and using it on a constant expression like "SomeName" would also be safer, even if the provider name should exist. In the loop below, c.getCurrencyCodes() being null would be another possible source for an NPE. That's why I wonder, if breakpoints allow to narrow it down.
Activity
keilw commentedon Nov 7, 2018
Was it possible to debug the code to see, which line throws the NPE?
In the first one swapping the
equals()method and using it on a constant expression like "SomeName" would also be safer, even if the provider name should exist. In the loop below,c.getCurrencyCodes()being null would be another possible source for an NPE. That's why I wonder, if breakpoints allow to narrow it down.