On Fri, 9 Sep 2022 06:45:04 GMT, Markus KARG <d...@openjdk.org> wrote:

>> test/jdk/java/io/BufferedInputStream/TransferTo.java line 170:
>> 
>>> 168:             if (mark) {
>>> 169:               in.mark(1);
>>> 170:             }
>> 
>> This just tests transferTo with a mark set, it doesn't appear to check that 
>> mark is respected. To test mark/reset then I think it will need to call mark 
>> with a largish readLimit, transferTo to drain the input to EOF, reset, and 
>> then read or transferTo again to check that the bytes from the mark are 
>> replayed.
>
> I did not do that so far, as we agreed to check the *new* code path, which is 
> only executed when noting was marked (so reset plays no role). Certainly I 
> will be happy to add another test for the use case you describe (i. e. the 
> *old* code path), even if we all know -thanks to our knowledge of the 
> existence of the two code paths-, that it will surely pass even with my PR in 
> place, unless there is a bug in the *old* code path... ;-)

Unless there's a bug and the new code path is triggered when there's a mark ;-) 
. Maybe we can convince ourselves that this can't happen now (by reading the 
code), but if someone modifies this code 2 years from now and introduces a bug 
that changes that it would be good to have a test to catch it.

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

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

Reply via email to