RFR: 8294047: HttpResponseInputStream swallows interrupts

Daniel Fuchs dfuchs at openjdk.org
Wed Nov 23 15:13:04 UTC 2022


On Wed, 23 Nov 2022 14:21:13 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.

test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java line 87:

> 85:             Thread interrupterThread = new Thread(() -> {
> 86:                 try {
> 87:                     countDownLatch.await();

It would be useful to add a comment before waiting on the latch to explain what you are waiting for.

test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java line 107:

> 105:     static class Handler implements HttpHandler {
> 106: 
> 107:         CountDownLatch countDownLatch;

Maybe a better name than `countDownLatch` could be found - that could give a clue on what this latch is used to wait for?

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

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


More information about the net-dev mailing list