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

Reviewed-by: rriggs, lancea, alanb
This commit is contained in:
Brian Burkhalter 2023-06-27 15:28:01 +00:00
parent 05e9c41edd
commit 58bb6555e7
3 changed files with 23 additions and 12 deletions

View file

@ -189,14 +189,18 @@ public abstract class Reader implements Readable, Closeable {
* Attempts to read characters into the specified character buffer.
* The buffer is used as a repository of characters as-is: the only
* changes made are the results of a put operation. No flipping or
* rewinding of the buffer is performed.
* rewinding of the buffer is performed. If the {@linkplain
* java.nio.CharBuffer#length length} of the specified character
* buffer is zero, then no characters will be read and zero will be
* returned.
*
* @param target the buffer to read characters into
* @return The number of characters added to the buffer, or
* -1 if this source of characters is at its end
* @return The number of characters added to the buffer,
* possibly zero, or -1 if this source of characters is at its end
* @throws IOException if an I/O error occurs
* @throws NullPointerException if target is null
* @throws java.nio.ReadOnlyBufferException if target is a read only buffer
* @throws java.nio.ReadOnlyBufferException if target is a read only buffer,
* even if its length is zero
* @since 1.5
*/
public int read(CharBuffer target) throws IOException {