RFR: 8294047: HttpResponseInputStream swallows interrupts [v9]

Jaikiran Pai jpai at openjdk.org
Mon Dec 5 07:19:54 UTC 2022


On Fri, 2 Dec 2022 16:17:32 GMT, Darragh Clarke <duke at openjdk.org> wrote:

>> Currently if a `HttpResonseInputStream` gets interrupted while reading it will just swallow the exception and continue,
>> 
>> This PR changes it to close the stream and throw an IOException, I added a test to cover this which just uses two threads to read the stream then interrupt it.
>
> Darragh Clarke has updated the pull request incrementally with one additional commit since the last revision:
> 
>   check thread interrupt status is set

src/java.net.http/share/classes/java/net/http/HttpResponse.java line 1181:

> 1179:          * from being reused for subsequent operations.
> 1180:          *
> 1181:          * @implNote The read method of the default implementation returned

Hello Darragh, should we instead reword this as:

> @implNote The {@code read} method of the {@code InputStream} returned by the default implementation of this method will throw an {@code IOException} with the {@link Thread#isInterrupted() thread interrupt status set} if the thread is interrupted while blocking on read. In that case, the request will also be cancelled and the {@code InputStream} will be closed.

Additionally, irrespective of whether or not we decide to reword this, this file will need an update for the copyright year.

src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java line 32:

> 30: import java.io.IOException;
> 31: import java.io.InputStream;
> 32: import java.io.InterruptedIOException;

I think this is now an unused import and we can remove it?

-------------

PR: https://git.openjdk.org/jdk/pull/11323


More information about the net-dev mailing list