-
Notifications
You must be signed in to change notification settings - Fork 75
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
URLThreeArgumentConstructor
does not introduce newly thrown exception
#467
Comments
This recipe is implemented as a Refaster recipe, and as such it's well possible the fix should land in https://github.com/openrewrite/rewrite-templating to introduce the new exception there from what's thrown in the after template method. /cc @knutwannheden |
Hey @timtebeek I have a suggestion on this issue
This ensures that the throws URISyntaxException is correctly propagated in the converted code, addressing the issue you encountered. What are your thoughts @timtebeek over this ? |
Hi! Thanks for the suggestion; the way that our rewrite-templating converts Refaster templates to OpenRewrite recipes does not yet include adding a throws declaration where necessary. It might be more complicated to add that there, but would indeed be helpful here. Note that our implementation of Refaster is different from ErrorProne itself, if you're familiar with how ErrorProne works. |
Similar issue here package org.jabref.logic.importer.fetcher;
import java.io.IOException;
+import java.net.URI;
import java.net.URL;
import java.util.Objects;
import java.util.Optional;
import org.jabref.logic.importer.FulltextFetcher;
@@ -60,11 +61,11 @@ public class SpringerLink implements FulltextFetcher, CustomizableKeyFetcher {
JSONObject json = jsonResponse.getBody().getObject();
int results = json.getJSONArray("result").getJSONObject(0).getInt("total");
if (results > 0) {
LOGGER.info("Fulltext PDF found @ Springer.");
- return Optional.of(new URL("http", CONTENT_HOST, "/content/pdf/%s.pdf".formatted(doi.get().getDOI())));
+ return Optional.of(new URI("http", null, CONTENT_HOST, -1, "/content/pdf/%s.pdf".formatted(doi.get().getDOI()), null, null).toURL());
}
}
} catch (UnirestException e) {
LOGGER.warn("SpringerLink API request failed", e);
} |
What version of OpenRewrite are you using?
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
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
What did you see instead?
Note the lacking
throws URISyntaxException
.What is the full stack trace of any errors you encountered?
Compiler error, as
URISyntaxException
does not extendIOException
, in contrast toMalformedURLException
thrown before. As reported by @IanDarwinThe text was updated successfully, but these errors were encountered: