[BUG] InputStream.readNBytes doesn't correctly check for EOF
Philippe Marschall
kustos at gmx.net
Tue Dec 22 17:36:43 UTC 2020
On 20.12.20 19:15, Philippe Marschall wrote:
>
>
> On 20.12.20 18:47, Rob Spoor wrote:
>> ...
>>
>> That "> 0" is incorrect here; it's allowed to return 0 before EOF
>
> I don't think the method is allowed to return 0 before EOF. To quote
> from the method Javadoc.
>
> > This method blocks until input data is available, end of file is
> detected, or an exception is thrown.
>
> > If no byte is available because the stream is at end of file, the
> value {@code -1} is returned; otherwise, at least one byte is read and
> stored into {@code b}.
Hello Rob
For whatever reason I see your reply only in the web interface and not
in my mail client so I reply to my mail instead.
The Javadoc I posted is from InputStream.read(byte[], int, int).
Therefore I don't think that InputStream.read(byte[], int, int) is
allowed to return 0 unless len is 0 in which case the loop is supposed
to terminate.
Cheers
Philippe
More information about the core-libs-dev
mailing list