RFR: 8271308: (fc) FileChannel.transferTo() transfers no more than Integer.MAX_VALUE bytes in one call
Alan Bateman
alanb at openjdk.java.net
Sun Aug 1 08:00:47 UTC 2021
On Thu, 29 Jul 2021 23:08:58 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Please consider this request to enhance `java.nio.channels.FileChannel.transferTo()` to be able to transfer more than `Integer.MAX_VALUE` bytes in one call.
Changes requested by alanb (Reviewer).
src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java line 705:
> 703: break;
> 704: position += n;
> 705: bytesTransferred += n;
I think this patch is problematic for the cases where the second (or subsequent) call to transferTo fails transferToArbitraryChannel has to deal with this by returning the number of bytes transferred before the error.
I think it might be better to just continue with having transferTo map to one syscall where possible. In this case I'd prefer not introduce a loop but instead just use the OS "max transfer size" to cap the number of bytes transferred in one call to this method.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4940
More information about the nio-dev
mailing list