RFR: 8278268 - (ch) InputStream returned by Channels.newInputStream should have fast path for FileChannel targets [v21]
Brian Burkhalter
bpb at openjdk.org
Mon Mar 20 21:03:56 UTC 2023
On Sat, 18 Mar 2023 16:35:15 GMT, Markus KARG <duke at openjdk.org> wrote:
>> This sub-issue defines the work to be done to implement JDK-8265891 solely for the particular case of FileChannel.transferFrom(ReadableByteChannel), including special treatment of SelectableByteChannel.
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>
> Abstracted testMoreThanTwoGB
test/jdk/java/nio/channels/Channels/TransferToBase.java line 222:
> 220: byte[] rndBytes = createRandomBytes(BYTES_PER_WRITE, 0);
> 221: ByteBuffer src = ByteBuffer.wrap(rndBytes);
> 222: fc.write(src);
Should this code perhaps allow for a short write, i.e., `FileChannel::write` returning a value less than `rndBytes.length`? For example, something like this:
long pos = initPos;
while (pos < BYTES_WRITTEN) {
int len = Math.toIntExact(BYTES_WRITTEN - pos);
if (len > BYTES_PER_WRITE)
len = BYTES_PER_WRITE;
byte[] rndBytes = createRandomBytes(len, 0);
ByteBuffer src = ByteBuffer.wrap(rndBytes);
pos += fc.write(src);
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/6711#discussion_r1142672553
More information about the nio-dev
mailing list