-
Notifications
You must be signed in to change notification settings - Fork 83
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
Improve Handling of Absolute, Relative, and Non-Literal URLs in URL Migration #678
Improve Handling of Absolute, Relative, and Non-Literal URLs in URL Migration #678
Conversation
src/main/java/org/openrewrite/java/migrate/net/URLConstructorsToURI_mock.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
These changes only modify the behavior of the single argument constructor for Case 1: The argument is a string literal of an absolute path
After:
Case 2: The argument is a string literal of a relative path
Case 3: The argument is a not a string literal (it could be a constant, local variable, method invocation, etc)
After:
|
I feel case 3 might be quite surprising to see for folks. Would it not be better to hold off on making any change there, and potentially attempt to resolve constants as seen here? Any cases not yet converted we can then remove in a future Java version of the old constructors are removed. Until then a deprecation warning might be preferred. |
Sure, we can update case 3 here. If the parameter is a constant, we can attempt to resolve it as you mentioned. If the parameter is not a string literal nor a constant, then we will make no changes. |
9082240
to
e050ff3
Compare
Hi @rlsanders4 I've added a Precondition to prevent executions on From the logical perspective, all was good 👍 |
What's changed?
What's your motivation?
Anything in particular you'd like reviewers to focus on?
Ensure that the fallback to convertURI(spec) for relative URLs behaves as expected, and that absolute URLs continue to be handled correctly.
Any additional context
This is part of the migration from new URL(String spec) to URI.create(String).toURL(). By making this change, we ensure consistent handling of URLs in code.
Checklist