RFR: 8275840: Testing FileChannel.transferTo(FileChannel) with more than 2 GB of data

Brian Burkhalter bpb at openjdk.java.net
Mon Oct 25 19:56:03 UTC 2021


On Sat, 23 Oct 2021 15:51:20 GMT, Markus KARG <duke at openjdk.java.net> wrote:

> Testing `FileChannel.transferTo(FileChannel)` with more than 2 GB of data is covering the case that *multiple* iterations of `FileChannel.transferTo(FileChannel)` are actually performed by the test.
> 
> This change was requested Alan Bateman @AlanBateman.

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.

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

PR: https://git.openjdk.java.net/jdk/pull/6093


More information about the nio-dev mailing list