RFR: 7026262: HttpServer: improve handling of finished HTTP exchanges [v2]
Daniel Jeliński
djelinski at openjdk.org
Fri Mar 24 11:13:36 UTC 2023
On Thu, 23 Mar 2023 18:39:22 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> 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
>
> src/jdk.httpserver/share/classes/sun/net/httpserver/FixedLengthOutputStream.java line 76:
>
>> 74: if (eof) {
>> 75: throw new StreamClosedException();
>> 76: }
>
> Maybe before checking `closed` we should just return if len == 0? (and throw if < 0 BTW)
> Possibly consider doing the same for ChunkedOutputStream.
> Also ChunkedOutputStream throws StreamClosedException() when `closed` is true. Not sure why we're throwing plain IO here. Or rather - not sure why we have StreamClosedException() in the first place, it doesn't seem to be handled specially anywhere, and it can reach user code (code calling write()), and it's not a public exception - so maybe it should be removed altogether and replaced with IOException("stream closed") everywhere? But getting rid of StreamClosedException may be a task for another PR.
+1. Filed [JDK-8304873](https://bugs.openjdk.org/browse/JDK-8304873) to remove `StreamClosedException`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13157#discussion_r1147435368
More information about the net-dev
mailing list