RFR: 7026262: HttpServer: improve handling of finished HTTP exchanges [v2]
Michael McMahon
michaelm at openjdk.org
Fri Mar 24 15:58:49 UTC 2023
On Fri, 24 Mar 2023 10:56:50 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
>> This patch fixes the following issues with HttpHandler exception handling:
>> - The connection is no longer closed if an exception is thrown after the response is completed. As soon as the response is completed, the connection is added back to the pool, ready for reuse. Closing the connection would race with the subsequent handler.
>> - The stream returned by `getResponseBody` is now usable even if the response has zero-length body. Writing any data to the stream will still fail, but zero-length writes and closing the stream will now succeed.
>> - `ServerImpl.Exchange.reject` now sends a `Connection: close` header in addition to closing the connection
>>
>> The test `B8293562` had to be adjusted to avoid `Connection: close`.
>> Additionally, while I was looking for a good test to copy from, I found and fixed a bug in test `B5045306`.
>>
>> The new tests are passing with this patch, failing without it. Tier 1-3 clean.
>
> Daniel Jeliński has updated the pull request incrementally with three additional commits since the last revision:
>
> - Explicit close no longer needed
> - Close exchange on zero-length response
> - Remove redundant closeConnection
Looks fine to me
src/jdk.httpserver/share/classes/sun/net/httpserver/ChunkedOutputStream.java line 86:
> 84: return;
> 85: }
> 86: if (closed) {
Initially I didnt think the above was a great idea as OutputStream.write is spec'd to throw IOE if the stream is closed, but it appears that some commonly used OutputStream classes are tolerant of zero length writes
-------------
Marked as reviewed by michaelm (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13157#pullrequestreview-1356942313
PR Review Comment: https://git.openjdk.org/jdk/pull/13157#discussion_r1147736808
More information about the net-dev
mailing list