RFR: 8294047: HttpResponseInputStream swallows interrupts [v8]
    Daniel Fuchs 
    dfuchs at openjdk.org
       
    Fri Dec  2 15:50:22 UTC 2022
    
    
  
On Fri, 2 Dec 2022 15:34:55 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 cause of exception in test
test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java line 171:
> 169:                 var thrown = assertThrows(IOException.class, () -> response.body().readAllBytes(), "expected IOException");
> 170:                 var cause = thrown.getCause();
> 171:                 assertTrue(cause instanceof InterruptedException, cause + " is not an InterruptedException");
Ah - and of course the test should verify that the thread interrupted status is set too, since we specified that :-)
var thread = Thread.currentThread();
assertTrue(thread.isInterrupted(), "Thread " + thread + " is not interrupted");
-------------
PR: https://git.openjdk.org/jdk/pull/11323
    
    
More information about the net-dev
mailing list