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

Catch non-semver compatible exception in case of version update #4656

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

Jenson3210
Copy link
Contributor

@@ -262,7 +262,7 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
acc.versionPropNameToGA.put(versionVariableName, ga);
acc.gaToNewVersion.put(ga, resolvedVersion);
}
} catch (MavenDownloadingException e) {
} catch (IllegalStateException | MavenDownloadingException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should instead be fixed here:
https://github.com/openrewrite/rewrite/blob/main/rewrite-gradle%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenrewrite%2Fgradle%2FDependencyVersionSelector.java#L168

The rationale is that the version is being compared and should really be skipped as exotic. The DependencyVersionSelector is used in several spots all of which could encounter this exact same issue. By moving this fix to the location in the link, we'll fix all of the recipes in one fell swoop.

Copy link
Contributor Author

@Jenson3210 Jenson3210 Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider that also. However, I thought "If you use the versionSelector, you know that a version is selectable".

What would you return if no version could be selected? Null? I thought not all usages of that class might work with that.

But you know this part 10 times better so if you think it is safe, I am 100% agreeing!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shanman190 moved the check to the proposed position!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

Yeah, the version selector is simply trying to answer the question of: "is there a version to which we can upgrade to?" At which point, the version selector should return only the value to be upgraded to or null to indicate that there was no upgrade available or possible. In particular, with versions like the one from the issue, there's less of a natural order (outside of ASCII) in order to ensure that we are moving up the version strictly. This appears as well with the old Spring Cloud release trains where they were using the alpha ordering of train stations across Europe to order their releases (ie. Angel, Brixton, Camden, etc).

@Jenson3210
Copy link
Contributor Author

Fixes #4654

@Jenson3210 Jenson3210 closed this Nov 11, 2024
@Jenson3210 Jenson3210 deleted the issue_4655 branch November 11, 2024 09:15
@Jenson3210 Jenson3210 restored the issue_4655 branch November 11, 2024 11:47
@Jenson3210 Jenson3210 reopened this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants