RFR: 8304963: HttpServer closes connection after processing HEAD after JDK-7026262
Daniel Fuchs
dfuchs at openjdk.org
Mon Mar 27 19:02:22 UTC 2023
On Mon, 27 Mar 2023 18:37:58 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
> This PR fixes a regression introduced in [JDK-7026262](https://bugs.openjdk.org/browse/JDK-7026262); we started closing the exchange instead of the output stream, and exchange closes the connection when wrapped stream is not set. As an unintended side effect, the server started closing connections after handling a HEAD request.
>
> The proposed change is to set the wrapped stream to a zero-length FixedLengthOutputStream before closing the exchange. This allows the connection to be reused.
>
> The attached test verifies if 2 consecutive HEAD requests use the same connection. It succeeds with the proposed change, fails without it. All other tier1-3 tests continue to pass.
Good finding. We missed the case where the response output stream didn't get wrapped for the HEAD request which caused the socket stream to get closed.
The HTTP server in the new test will only triggers if the URI path is /firstCall or /secondCall so it should hopefully be resilient to random connections.
Please verify the new (and old) tests are stable before integrating.
-------------
Marked as reviewed by dfuchs (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13193#pullrequestreview-1359703061
More information about the net-dev
mailing list