RFR: 8222329: Readable read(CharBuffer) does not specify that 0 is returned when there is no remaining space in buffer

Brian Burkhalter bpb at openjdk.org
Thu Jun 22 19:04:04 UTC 2023


On Thu, 22 Jun 2023 18:43:19 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Clarify the behavior of `java.lang.Readable` when the specified `java.nio.CharBuffer` parameter is empty but read-only, and when it is full.
>
> src/java.base/share/classes/java/lang/Readable.java line 49:
> 
>> 47:      * @param cb the buffer to read characters into
>> 48:      * @return The number of {@code char} values added to the buffer,
>> 49:      *         possibly zero, or -1 if this source of characters is at its end
> 
> Would it be clearer to specifically indicate 0 is returned when no characters will be read.

Might be. I was mimicking the return specification from [FileChannel::read](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/nio/channels/FileChannel.html#read(java.nio.ByteBuffer[],int,int)).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14616#discussion_r1238922106


More information about the nio-dev mailing list