RFR: 8275840: Testing FileChannel.transferTo(FileChannel) with more than 2 GB of data [v2]
Markus KARG
duke at openjdk.java.net
Tue Oct 26 06:59:36 UTC 2021
On Mon, 25 Oct 2021 19:53:01 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Markus KARG has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Also it would be better to use constants.
>> - It would probably be better to use a try-with-resources statement here to cleanly close the streams.
>
> test/jdk/java/nio/channels/Channels/TransferTo.java line 147:
>
>> 145: // performing actual transfer, effectively by multiple invocations of Filechannel.transferTo(FileChannel)
>> 146: InputStream inputStream = Channels.newInputStream(FileChannel.open(sourceFile));
>> 147: OutputStream outputStream = Channels.newOutputStream(FileChannel.open(targetFile, StandardOpenOption.WRITE));
>
> It would probably be better to use a try-with-resources statement here to cleanly close the streams.
Done in b12d39c2ca870d6cdc2bc8e1ae123b80a0517479.
> test/jdk/java/nio/channels/Channels/TransferTo.java line 151:
>
>> 149:
>> 150: // comparing reported transferred bytes, must be 3 GB
>> 151: assertEquals(count, 3L * 1024 * 1024 * 1024);
>
> Also it would be better to use constants. One option is
>
> int NUM_WRITES = 3*1024;
> int BYTES_PER_WRITE = 1024*1024;
>
> in which case the second parameter of the first `assertEquals()` would be `(long)NUM_WRITES*BYTES_PER_WRITE`.
Done in b12d39c2ca870d6cdc2bc8e1ae123b80a0517479.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6093
More information about the nio-dev
mailing list