-
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?
- OpenRewrite v8.24.0
- rewrite-migrate-java v2.12.0
How are you running OpenRewrite?
I'm running org.openrewrite.java.migrate.net.URLConstructorsToURI.URLThreeArgumentConstructorRecipe, via:
rewrite-migrate-java/src/main/java/org/openrewrite/java/migrate/net/URLConstructorsToURI.java
Lines 44 to 58 in f399d72
| description = "Converts `new URL(String, String, String)` constructors to `new URI(...).toURL()`." | |
| ) | |
| public static class URLThreeArgumentConstructor { | |
| @BeforeTemplate | |
| URL urlConstructor(String protocol, String host, String file) throws Exception { | |
| return new URL(protocol, host, file); | |
| } | |
| @AfterTemplate | |
| URL newUriToUrl(String protocol, String host, String file) throws Exception { | |
| return new URI(protocol, null, host, -1, file, null, null).toURL(); | |
| } | |
| } | |
| @RecipeDescriptor( |
What is the smallest, simplest way to reproduce the problem?
class A {
URL urlConstructor(String protocol, String host, String file) throws IOException {
return new URL(protocol, host, file);
}
}What did you expect to see?
class A {
URL urlConstructor(String protocol, String host, String file) throws URISyntaxException, IOException {
return new URI(protocol, null, host, -1, file, null, null).toURL();
}
}What did you see instead?
class A {
URL urlConstructor(String protocol, String host, String file) throws IOException {
return new URI(protocol, null, host, -1, file, null, null).toURL();
}
}Note the lacking throws URISyntaxException.
What is the full stack trace of any errors you encountered?
Compiler error, as URISyntaxException does not extend IOException, in contrast to MalformedURLException thrown before. As reported by @IanDarwin
junior
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done