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

Redundant null check for JDK maps in generated code #1424

Closed
saarmbruster opened this issue Dec 20, 2022 · 0 comments · Fixed by #1425
Closed

Redundant null check for JDK maps in generated code #1424

saarmbruster opened this issue Dec 20, 2022 · 0 comments · Fixed by #1425

Comments

@saarmbruster
Copy link

bc4493a introduces a redundant null check for JDK maps. I found this because Spotbugs complains abound loading a known null value. The generated code looks like the following example:

if (v == null) Objects.requireNonNull(v, "value for key: " + k);

Obviously, it makes no sense to call Objects.requireNonNull() on a value known to be null. The if (v == null) is new since the mentioned commit. I don't think this should be there. Without it the code looks fine to me.

saarmbruster pushed a commit to saarmbruster/immutables that referenced this issue Dec 20, 2022
saarmbruster pushed a commit to saarmbruster/immutables that referenced this issue Mar 15, 2023
elucash added a commit that referenced this issue Mar 15, 2023
Fix #1424 - redundant null check in JDK maps
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

Successfully merging a pull request may close this issue.

1 participant