On Fri, 2 Jul 2021 16:58:18 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

>> Modify the specification of 
>> `java.io.ByteArrayInputStream#read(byte[],int,int)` to indicate that `-1` is 
>> returned instead of `0` when the stream is at its end and the third 
>> parameter, `len`, is zero.
>
> Brian Burkhalter has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   6766844: Correct error messages in test

src/java.base/share/classes/java/io/ByteArrayInputStream.java line 161:

> 159:      * Unlike the {@link InputStream#read(byte[],int,int) overridden 
> method}
> 160:      * of {@code InputStream}, this method returns {@code -1} instead of 
> zero
> 161:      * if the end of the stream has been reached and {@code len == 0}.

The statement "return -1 if the end of the stream has been reached and len == 
0" gives an impression that it requires both conditions to be met: end of the 
stream && len==0,  but the tests show -1 is expected if len == 0 without an 
attempt to read the stream. 

The overridden method stated that "If len is zero, then no bytes are read and 0 
is returned", the above note looks like was meant for this statement since the 
overridden method also return -1 if the stream is at end of file.

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

PR: https://git.openjdk.java.net/jdk17/pull/189

Reply via email to