On Mon, 17 Oct 2022 07:46:46 GMT, Jaikiran Pai <[email protected]> wrote:
>> 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.
Yes - the first time around we don't read anything and we cancel right away.
The second time around we read something and then we cancel.
-------------
PR: https://git.openjdk.org/jdk/pull/10659