RFR: 8286200: SequenceInputStream::read(b, off, 0) returns -1 at EOF
Brian Burkhalter
bpb at openjdk.java.net
Wed May 11 20:57:19 UTC 2022
On Wed, 11 May 2022 20:47:52 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Modify the specification of `SequenceInputStream.read(byte[],int,int)` to indicate that `-1` is returned at the EOF of the last stream even if `len` is zero.
The `InputStream.read(byte[],int,int)` specification indicates
If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt
to read at least one byte. If no byte is available because the stream is at end of file,
the value -1 is returned; otherwise, at least one byte is read and stored into b.
so that zero should be returned if `len` is zero regardless of anything else. `SequenceInputStream` does not follow this so its specification should be modified to document the existing, longstanding behavior.
A CSR will be filed once there is consensus here.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8664
More information about the core-libs-dev
mailing list