RFR: JDK-8260694: (fc) Add apiNote to FileChannel.transferFrom to better describe "no bytes available" case [v3]

Brian Burkhalter bpb at openjdk.java.net
Wed Feb 3 02:09:44 UTC 2021


On Wed, 3 Feb 2021 01:22:59 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> We'd better put more detailed messages in FileChannel.transferFrom/transferTo that it will not return -1, as we met several cases where developers of framework/program assume that it will return -1 on some error conditions, e.g. EOF of src Channel of transferFrom.
>> 
>> please check more details in JDK-8260486, and discussion in https://mail.openjdk.java.net/pipermail/nio-dev/2021-January/008094.html
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JDK-8260694: (fc) Add apiNote to FileChannel.transferFrom to better describe "no bytes available" case

src/java.base/share/classes/java/nio/channels/FileChannel.java line 646:

> 644:      * and has fewer than {@code count} bytes immediately available in its
> 645:      * input buffer. No bytes are transferred if the source channel has reached
> 646:      * end-of-stream.

How about `* end-of-stream in which case zero will be returned.`?

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

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


More information about the nio-dev mailing list