Open JosRoseboom opened 1 year ago
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 org.openrewrite.java.migrate.util.JavaUtilAPIs
which in turn is part of org.openrewrite.java.migrate.Java8toJava11
. Since all of the recipes in org.openrewrite.java.migrate.util.JavaUtilAPIs
have this flaw, we should probably remove org.openrewrite.java.migrate.util.JavaUtilAPIs
entirely from org.openrewrite.java.migrate.Java8toJava11
.
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.