RFR: 8325382: (fc) FileChannel.transferTo throws IOException when position equals size

Alan Bateman alanb at openjdk.org
Sat Feb 10 16:09:03 UTC 2024


On Fri, 9 Feb 2024 19:55:15 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> In `FileChannelImpl.transferTo`, do not clamp the number of bytes to transfer to the number remaining in the source `FileChannel` unless the size of the source is positive. When clamping, do not use the strict inequality `remaining > 0`, but rather allow clamping to zero.

test/jdk/java/nio/channels/FileChannel/Transfer.java line 182:

> 180:             // FileChannelImpl.MAPPED_TRANSFER_THRESHOLD which is
> 181:             // currently 16384
> 182:             chSource.transferTo(length, 16385, chTarget);

"transferToTrusted" hints that this method will test a trusted target but it's actually a very specific test that doesn't test all trusted scenarios, and doesn't even check the return from transferTo. So I think this one is really a regression test that checks that it doesn't throw.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17796#discussion_r1485183491


More information about the nio-dev mailing list