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

Checks.checkNotNull should emit IllegalArgumentException instead of NPE #554

Closed
mockitoguy opened this issue Aug 14, 2016 · 2 comments
Closed
Assignees

Comments

@mockitoguy
Copy link
Member

Checks.checkNotNull emits NPE. I think it is better to emit IAE, because:

  • IAE is more specific whereas NPE is more generic. Specific exception is easier to test.
  • Specific exception gives better experience for users, NPE is often assumed to be developer error.

This change is not backwards compatible.

@bric3, thoughts?

@marcingrzejszczak
Copy link
Collaborator

Definitely! Personally I hate throwing NPEs. NPE can be thrown because you've forgotten to inject sth and your test (if you test for an NPE exception to be thrown) will pass.

@bric3
Copy link
Contributor

bric3 commented Aug 15, 2016

Agreed

@bric3 bric3 self-assigned this Aug 16, 2016
@bric3 bric3 closed this as completed in 4324383 Aug 16, 2016
bric3 added a commit that referenced this issue Aug 16, 2016
Fixes #554 : Checks.checkNotNull now throws IAE instead of NPE
@bric3 bric3 removed the in progress label Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants