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

Alan Bateman alanb at openjdk.java.net
Wed Feb 3 08:10:43 UTC 2021


On Wed, 3 Feb 2021 05:27:20 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Given the other verbiage I don't think that an `apiNote` is actually necessary.
>
> Hi Brian, 
> At the beginning, I don't think this patch is necessary, because I think if I read really carefully, then I can avoid the misuse.
> But the truth is there are several misuse cases, not just in my company, several are in opensource projects. So, I think it's worth to emphasize it even if it's a little redudant.
> How do you think about it?

The transferXXX methods return the number of bytes that were transferred to or from the file so there should be no expectation that -1 is returned. My preference would be to just clarify the transferFrom javadoc to make it clear that zero is returned when the source has reached end-of-stream.

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

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


More information about the nio-dev mailing list