RFR: 8294916: Cancelling a request must eventually cause its response body subscriber to be unregistered [v4]

Jaikiran Pai jpai at openjdk.org
Mon Oct 17 07:49:14 UTC 2022


On Sat, 15 Oct 2022 06:49:20 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Daniel Fuchs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   More cleanup to the test
>
> test/jdk/java/net/httpclient/CancelStreamedBodyTest.java line 307:
> 
>> 305:                     for (int k = 0; k < j; k++) {
>> 306:                         read = is.read();
>> 307:                         assertEquals(read, BODY.charAt(k));
> 
> Hello Daniel, I don't follow this loop. The number of times it is iterating seems to be dependent on a statically decided value of `j` (which can't exceed 2). Each iteration it reads 1 byte and compares that byte with the pre-defined response content. Shouldn't this loop instead be doing `k < BODY.length();`?

Now that I think with a fresher mind, I see what this loop does - it intentionally doesn't read the entire response content and instead closes the stream before the whole response is read, to trigger the original issue.

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

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


More information about the net-dev mailing list