-
Notifications
You must be signed in to change notification settings - Fork 77
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
Collections.singleton and Collections.singletonList allow null, Set.of and List.of not #250
Comments
Hmm; that's odd; we had a similar case come up in review recently, where we specifically recommended to introduce data flow analysis before applying the change there; sounds like this recipe needs a similar change. Would you be open to making that change with help? |
In the short term it's probably best to disable this recipe in any collections of recipes; then people can still decide to run it explicitly but know they might need to review for nullability. |
Currently this recipe is part of |
Using openrewrite 6.1.8 using gradle:
This recipe replaces Collections.singleton with Set.of and Collections.singletonList by List.of . However, the former allows null while the latter does not. So these 2 lines:
are replaced by the recipe by:
which creates a potential NPE that would not happened in the original code.
The text was updated successfully, but these errors were encountered: