OfficeCurrency#equals throws NullPointerException when currency is null
adn35350 opened this issue ยท 1 comments
adn35350 commented
It's me again ๐
After the pull-request #48 the default currency was set to null instead of non-null currency (e.g : locale default currency). That's your choice but this creates a regression on OfficeCurrency#equals
method because variable that.currency
can be null.
Here is a simple JUnit test for this use case
@Test
void testOfficeCurrencyEqualsWithNullCurrency() {
final OfficeCurrency nonNullCurrency = new OfficeCurrency(Currency.getInstance(Locale.getDefault()), 5D);
final OfficeCurrency nullCurrency = new OfficeCurrency(null, 5D);
Assertions.assertFalse(nonNullCurrency.equals(nullCurrency));
}
Result :
java.lang.NullPointerException
at com.github.miachm.sods.OfficeCurrency.equals(OfficeCurrency.java:61)
miachm commented
Thanks for the report!
I think it's an edge case in the equals method. Easy fix.