Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfficeCurrency#equals throws NullPointerException when currency is null #53

Closed
adn35350 opened this issue Nov 29, 2022 · 1 comment
Closed

Comments

@adn35350
Copy link
Contributor

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
Copy link
Owner

miachm commented Dec 2, 2022

Thanks for the report!

I think it's an edge case in the equals method. Easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants