RFR: 8278268 - (ch) InputStream returned by Channels.newInputStream should have fast path for FileChannel targets [v21]
Markus KARG
duke at openjdk.org
Tue Mar 21 21:48:02 UTC 2023
On Mon, 20 Mar 2023 21:00:31 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> 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);
> }
I have incorporated your proposed code change.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/6711#discussion_r1144017216
More information about the nio-dev
mailing list