Closed blipper closed 4 months ago
Hi @blipper ; thanks for the suggestion! Up to now we hadn't yet made any recipe for this change as it's hard to tell when it's safe to do so. There's a subtle difference where collect(Collectors.toList())
returns a new ArrayList
(although it makes no such guarantees), whereas toList()
returns an immutable list (as you likely know already). We're tracking progress towards such a recipe along with our other upgrade recipes in https://github.com/openrewrite/rewrite-migrate-java/issues/83
I hope you don't mind me closing this issue to prevent duplicates; you're welcome to chime in on https://github.com/openrewrite/rewrite-migrate-java/issues/83 as to possible avenues here.
(And yes, I agree ReplaceStreamToListWithCollect.java is likely misplaced here)
What problem are you trying to solve?
We want to upgrade to from Java 11 to 17. ReplaceStreamToListWithCollect goes from 17-> 11.
What precondition(s) should be checked before applying this recipe?
Java 17
Describe the situation before applying the recipe
Invert https://github.com/openrewrite/rewrite-static-analysis/blob/c6e7a0f8cf9d424331845b688e51c71e1a46f363/src/test/java/org/openrewrite/staticanalysis/ReplaceStreamToListWithCollectTest.java
Have you considered any alternatives or workarounds?
Any additional context
Are you interested in [contributing this recipe to OpenRewrite]
Yes