apache / apache/maven-javadoc-plugin

[MJAVADOC-656] Following redirects breaks valid links

Open
#1,029 8 comments 0 reactions 0 assignees View on GitHub
bug priority:minor
Dominant language
Java
Stars
107
Forks
116
Avg merge
1d 10h
Merged PRs (30d)
16

Description

**[Robert Važan](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=robert.vazan)** opened **[MJAVADOC-656](https://issues.apache.org/jira/browse/MJAVADOC-656?redirect=false)** and commented

Version 3.0.1 fixed #427 by following redirects. This feature unfortunately breaks when HTTP server is configured as follows:

/apidocs/package-list -> 200
/apidocs -> 301 /apidocs/com/example/package-summary.html
/apidocs/ -> 301 /apidocs/com/example/package-summary.html
/apidocs/com/example/package-summary.html -> 200

Without following redirects (in version 3.0.0), the link is passed to javadoc tool unchanged, the javadoc tool fetches /apidocs/package-list, and everything works fine. Since 3.0.1, javadoc plugin follows one of the redirects (/apidocs or /apidocs/), passes the package summary URL to javadoc tool, which then fails like this:

[WARNING] javadoc: warning - Error fetching URL: https://example.com/apidocs/com/example/package-summary.html/

And if you have failOnWarnings set to true, this will fail the whole build.

The solution is fairly simple. Construct the whole URL (.../package-list) and follow redirects on that one. Then check whether the final destination ends in /package-list, strip the /package-list suffix, and pass the result to the javadoc tool.

---

**Affects:** 3.0.1, 3.2.0

**Issue Links:**
- [MJAVADOC-796](https://issues.apache.org/jira/browse/MJAVADOC-796) Do not follow links for Java 12+
(_**"requires"**_)

**Remote Links:**
- [Fixed in JDK-8190312
](https://bugs.openjdk.org/browse/JDK-8190312)
- [Logic in JDK
](https://github.com/battleblow/jdk/blob/975caf8457dd3424288cee1124d22f80ee05de70/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java#L149)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the redirect sequence described in the issue and trace how the Maven Javadoc Plugin prepares external links for the javadoc tool. Compare that behavior with the linked JDK Extern logic, including package-list handling, and verify that the final URL passed to javadoc resolves correctly without triggering failOnWarnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.