RFR: JDK-8299627: Fix/improve handling of "missing" element-list file
Hannes Wallnöfer
hannesw at openjdk.org
Thu Dec 7 14:12:09 UTC 2023
On Mon, 20 Nov 2023 23:25:38 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
> 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.
Looks good! Kudos for taking it upon yourself to write the test.
-------------
Marked as reviewed by hannesw (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/16751#pullrequestreview-1770230986
More information about the javadoc-dev
mailing list