-
Notifications
You must be signed in to change notification settings - Fork 109
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of OpenRewrite are you using?
I am using
- rewrite-rewrite-migrate-java 2.30.1
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
The following conversion by the URLConstructorsToURI recipe yields an IllegalArgumentException:
Before:
url = new URL("META-INF/wsdl/GarageSaleCCManagerService.wsdl");
After:
url = URI.create("META-INF/wsdl/GarageSaleStoreManagerService.wsdl").toURL()
Here is the full Stack Trace:
[INFO] [err] Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.IllegalArgumentException: URI is not absolute [in thread "Default Executor-thread-8"]
[INFO] [err] at java.base/java.net.URL.of(URL.java:862)
[INFO] [err] at java.base/java.net.URI.toURL(URI.java:1172)
[INFO] [err] at com.ibm.websphere.svt.gs.gsdb.jaxws.client.GarageSaleStoreManagerService.<clinit>(GarageSaleStoreManagerService.java:31)
It appears that the URI.create method expects an absolute URI. The proposal here is to attempt to validate that the String literal passed to the method is absolute before performing the conversion.
It's possible the following recipe might help here
RemoveStringFlag.java
private boolean isFeatureKey(Expression firstArgument) {
return CursorUtil.findCursorForTree(getCursor(), firstArgument)
.bind(c -> ConstantFold.findConstantLiteralValue(c, String.class))
.map(featureKey::equals)
.orSome(false);
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done