Skip to content

Commit 43e901f

Browse files
committed
Improve URL handling
1 parent cb10f78 commit 43e901f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ private ClassLoader getProjectClassLoader() throws MojoExecutionException {
836836
for (String filename : classPath) {
837837
try {
838838
urls.add(new File(filename).toURI().toURL());
839-
} catch (MalformedURLException e) {
839+
} catch (MalformedURLException | IllegalArgumentException e) {
840840
throw new MojoExecutionException("MalformedURLException: " + e.getMessage(), e);
841841
}
842842
}

src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -5421,7 +5421,7 @@ private URL getResource(final List<String> classPath, final String resource) {
54215421
for (String filename : classPath) {
54225422
try {
54235423
urls.add(new File(filename).toURI().toURL());
5424-
} catch (MalformedURLException e) {
5424+
} catch (MalformedURLException | IllegalArgumentException e) {
54255425
getLog().error("MalformedURLException: " + e.getMessage());
54265426
}
54275427
}
@@ -5758,8 +5758,11 @@ private Set<String> followLinks(Set<String> links) {
57585758
Set<String> redirectLinks = new LinkedHashSet<>(links.size());
57595759
for (String link : links) {
57605760
try {
5761-
redirectLinks.add(JavadocUtil.getRedirectUrl(new URI(link).toURL(), settings)
5762-
.toString());
5761+
redirectLinks.add(
5762+
JavadocUtil.getRedirectUrl(new URL(link), settings).toString());
5763+
} catch (MalformedURLException | IllegalArgumentException e) {
5764+
// only print in debug, it should have been logged already in warn/error because link isn't valid
5765+
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
57635766
} catch (IOException e) {
57645767
// only print in debug, it should have been logged already in warn/error because link isn't valid
57655768
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
@@ -5768,9 +5771,6 @@ private Set<String> followLinks(Set<String> links) {
57685771
// incomplete redirect configuration on the server side.
57695772
// This partially restores the previous behaviour before fix for MJAVADOC-427
57705773
redirectLinks.add(link);
5771-
} catch (URISyntaxException | IllegalArgumentException e) {
5772-
// only print in debug, it should have been logged already in warn/error because link isn't valid
5773-
getLog().debug("Could not follow " + link + ". Reason: " + e.getMessage());
57745774
}
57755775
}
57765776
return redirectLinks;
@@ -5818,6 +5818,7 @@ protected boolean isValidJavadocLink(String link, boolean detecting) {
58185818
return true;
58195819
}
58205820
} catch (IOException e) {
5821+
// ignore this because it is optional
58215822
}
58225823

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

58375838
return false;
5838-
} catch (URISyntaxException e) {
5839+
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
58395840
if (getLog().isErrorEnabled()) {
58405841
if (detecting) {
5841-
getLog().warn("Malformed link: " + e.getInput() + ". Ignored it.");
5842+
getLog().warn("Malformed link: " + e.getMessage() + ". Ignored it.");
58425843
} else {
5843-
getLog().error("Malformed link: " + e.getInput() + ". Ignored it.");
5844+
getLog().error("Malformed link: " + e.getMessage() + ". Ignored it.");
58445845
}
58455846
}
58465847
return false;

0 commit comments

Comments
 (0)