RFR: JDK-8299627: Fix/improve handling of "missing" element-list file
Jonathan Gibbons
jjg at openjdk.org
Mon Nov 20 23:32:20 UTC 2023
Please review a relatively simple fix to work around weirdly configured web servers.
As first reported in this email, https://mail.openjdk.org/pipermail/javadoc-dev/2023-January/005502.html
`docs.oracle.com` will redirect links to https://docs.oracle.com/javase/8/docs/api/element-list to https://docs.oracle.com/en/java/javase/19/ even though the content of the page is completely different, and not as expected.
It was true back when the email discussion happened, and it is still true today (November 20, 2023).
For more details: see this:
$ curl --head https://docs.oracle.com/javase/8/docs/api/element-list
HTTP/1.1 302 Moved Temporarily
Location: https://docs.oracle.com/en/java/javase/21/
Content-Length: 1
Date: Mon, 20 Nov 2023 23:17:27 GMT
Connection: keep-alive
Compare this to accessing `package-list`
$ curl --head https://docs.oracle.com/javase/8/docs/api/package-list
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Type: text/plain
ETag: "a8e824353743394b56c8af52dce037a1:1697560290.919784"
Last-Modified: Wed, 04 Oct 2023 08:27:21 GMT
Server: AkamaiNetStorage
Content-Length: 4366
Date: Mon, 20 Nov 2023 23:20:35 GMT
Connection: keep-alive
In other words, we're getting `302 Moved Temporarily` instead of `404 Not Found`. Sigh.
So, with that as background, the fix is to check the end of the redirected URL against the end of the desired URL. to make sure they agree. In other words, we check that both end in `package-list` or `element-list` as appropriate.
The fix to the main code is almost trivial. The test is almost `noreg-hard` and primarily consists of setting up a weirdly configured local web server, to exercise different redirect policies.
-------------
Commit messages:
- JDK-8299627: Fix/improve handling of "missing" element-list file
Changes: https://git.openjdk.org/jdk/pull/16751/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16751&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8299627
Stats: 193 lines in 3 files changed: 191 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/16751.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16751/head:pull/16751
PR: https://git.openjdk.org/jdk/pull/16751
More information about the javadoc-dev
mailing list