RFR: JDK-8322141: SequenceInputStream.transferTo should not return as soon as Long.MAX_VALUE bytes have been transferred [v4]

Vladimir Sitnikov vsitnikov at openjdk.org
Sat Dec 16 19:13:41 UTC 2023


On Sat, 16 Dec 2023 14:07:52 GMT, Markus KARG <duke at openjdk.org> wrote:

>> Fixes JDK-8322141
>> 
>> As suggested by @vlsi and documented by @bplb this PR does not return, but only sets the maximum result value.
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Test was using Integer but must use Long

test/jdk/java/io/SequenceInputStream/TransferTo.java line 139:

> 137:         InputStream is1 = repeat(0, Long.MAX_VALUE);
> 138:         InputStream is2 = repeat(0, 1);
> 139:         assertNotEquals(is1.available(), 0);

Wdyt of asserting the expected value with assertEquals or removing the assertions before .transferTo altogether?
Suggestion:

        assertEquals(is1.available(), Integer.MAX_VALUE, "The stream should have Long.MAX_VALUE bytes .available() before .transferTo (.available returns int)");

test/jdk/java/io/SequenceInputStream/TransferTo.java line 143:

> 141:         SequenceInputStream sis = new SequenceInputStream(is1, is2);
> 142:         OutputStream nos = OutputStream.nullOutputStream();
> 143:         sis.transferTo(nos);

Suggestion:

        assertEquals(sis.transferTo(nos), Long.MAX_VALUE, ".transferTo should return Long.MAX_VALUE when transferring more than that amount of bytes");

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17119#discussion_r1428890685
PR Review Comment: https://git.openjdk.org/jdk/pull/17119#discussion_r1428891013


More information about the core-libs-dev mailing list