8286200: SequenceInputStream::read(b, off, 0) returns -1 at EOF

Reviewed-by: rriggs
This commit is contained in:
Brian Burkhalter 2022-05-16 15:42:29 +00:00
parent 743c779712
commit dbd3737085

View File

@ -162,10 +162,11 @@ public class SequenceInputStream extends InputStream {
} }
/** /**
* Reads up to {@code len} bytes of data from this input stream * Reads up to {@code len} bytes of data from this input stream into an
* into an array of bytes. If {@code len} is not zero, the method * array of bytes. If the end of the last contained stream has been reached
* blocks until at least 1 byte of input is available; otherwise, no * then {@code -1} is returned. Otherwise, if {@code len} is not zero, the
* bytes are read and {@code 0} is returned. * method blocks until at least 1 byte of input is available; if {@code len}
* is zero, no bytes are read and {@code 0} is returned.
* <p> * <p>
* The {@code read} method of {@code SequenceInputStream} * The {@code read} method of {@code SequenceInputStream}
* tries to read the data from the current substream. If it fails to * tries to read the data from the current substream. If it fails to
@ -180,8 +181,10 @@ public class SequenceInputStream extends InputStream {
* @return the total number of bytes read into the buffer, or * @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of * {@code -1} if there is no more data because the end of
* the last contained stream has been reached. * the last contained stream has been reached.
* @throws NullPointerException If {@code b} is {@code null}. * @throws NullPointerException if the end of the last contained
* @throws IndexOutOfBoundsException If {@code off} is negative, * stream has not been reached and {@code b} is {@code null}.
* @throws IndexOutOfBoundsException if the end of the last contained
* stream has not been reached and {@code off} is negative,
* {@code len} is negative, or {@code len} is * {@code len} is negative, or {@code len} is
* greater than {@code b.length - off} * greater than {@code b.length - off}
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.