Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve URL handling #310

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ private ClassLoader getProjectClassLoader() throws MojoExecutionException {
for (String filename : classPath) {
try {
urls.add(new File(filename).toURI().toURL());
} catch (MalformedURLException e) {
} catch (MalformedURLException | IllegalArgumentException e) {
throw new MojoExecutionException("MalformedURLException: " + e.getMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5421,7 +5421,7 @@ private URL getResource(final List<String> classPath, final String resource) {
for (String filename : classPath) {
try {
urls.add(new File(filename).toURI().toURL());
} catch (MalformedURLException e) {
} catch (MalformedURLException | IllegalArgumentException e) {
getLog().error("MalformedURLException: " + e.getMessage());
}
}
Expand Down Expand Up @@ -5758,8 +5758,11 @@ private Set<String> followLinks(Set<String> links) {
Set<String> redirectLinks = new LinkedHashSet<>(links.size());
for (String link : links) {
try {
redirectLinks.add(JavadocUtil.getRedirectUrl(new URI(link).toURL(), settings)
.toString());
redirectLinks.add(
JavadocUtil.getRedirectUrl(new URL(link), settings).toString());
} catch (MalformedURLException | IllegalArgumentException e) {
// only print in debug, it should have been logged already in warn/error because link isn't valid
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
} catch (IOException e) {
// only print in debug, it should have been logged already in warn/error because link isn't valid
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
Expand All @@ -5768,9 +5771,6 @@ private Set<String> followLinks(Set<String> links) {
// incomplete redirect configuration on the server side.
// This partially restores the previous behaviour before fix for MJAVADOC-427
redirectLinks.add(link);
} catch (URISyntaxException | IllegalArgumentException e) {
// only print in debug, it should have been logged already in warn/error because link isn't valid
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
}
}
return redirectLinks;
Expand Down Expand Up @@ -5818,6 +5818,7 @@ protected boolean isValidJavadocLink(String link, boolean detecting) {
return true;
}
} catch (IOException e) {
// ignore this because it is optional
}

if (JavadocUtil.isValidPackageList(packageListUri.toURL(), settings, validateLinks)) {
Expand All @@ -5835,12 +5836,12 @@ protected boolean isValidJavadocLink(String link, boolean detecting) {
}

return false;
} catch (URISyntaxException e) {
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
if (getLog().isErrorEnabled()) {
if (detecting) {
getLog().warn("Malformed link: " + e.getInput() + ". Ignored it.");
getLog().warn("Malformed link: " + e.getMessage() + ". Ignored it.");
} else {
getLog().error("Malformed link: " + e.getInput() + ". Ignored it.");
getLog().error("Malformed link: " + e.getMessage() + ". Ignored it.");
}
}
return false;
Expand Down