openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.29k stars 340 forks source link

IllegalStateException on latest.release comparison. #2267

Open jkschneider opened 2 years ago

jkschneider commented 2 years ago
  +~~(org.openrewrite.RecipeRunException: java.lang.IllegalStateException: Illegal State while comparing versions : [4aug2000r7.0.0-dev] and [4aug2000r7.0.0-dev]. Metadata = [4aug2000r7-dev-hudson-1]
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:253)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:240)
+  org.openrewrite.maven.ManageDependencies.lambda$visit$0(ManageDependencies.java:126)
+  java.base/java.util.Optional.map(Optional.java:260)
+  org.openrewrite.maven.ManageDependencies.lambda$visit$1(ManageDependencies.java:94)
+  org.openrewrite.internal.ListUtils.lambda$map$0(ListUtils.java:141)
+  org.openrewrite.internal.ListUtils.map(ListUtils.java:123)
+  org.openrewrite.internal.ListUtils.map(ListUtils.java:141)
+  ...)~~>Rewrite encountered an uncaught recipe error in org.openrewrite.maven.ManageDependencies.
\ No newline at end of file

Recipes in example diff:

mccartney commented 2 years ago

I suppose part of the problem is masking the exception at: https://github.com/openrewrite/rewrite/blob/0636039581aecce0c059434e3dd9b98954a8efa6/rewrite-core/src/main/java/org/openrewrite/semver/LatestRelease.java#L133-L136

mccartney commented 2 years ago

And I guess a simple fix and actually an optimization is to return early if the input String v1 is equal to String v2