Hi Sergey,

On Dec 8, 2017, at 4:34 PM, Sergey Bylokhov <sergey.bylok...@oracle.com> wrote:

> One more issue that according to the spec the new method
> read(byte[], int, int) should throw an exception if the stream was closed, 
> but as far as I understand it can return "0" if "len=0" even if the stream 
> was closed before:
>  99             @Override
> 100             public int read(byte[] b, int off, int len)
> 101                 Objects.checkFromIndexSize(off, len, b.length);
> 102                 if (len == 0) {
> 103                     return 0;
> 104                 }
> 105                 ensureOpen();
> 106                 return -1;
> 107             }

I agree it looks strange but it is intentional as it matches the existing 
InputStream.read(byte[],int,in) [1]. (I will remove line 167 as part of this 
patch.) Note that the IOE for the stream being closed would not be thrown in 
the current code until line 173.

Thanks,

Brian

[1] 
http://hg.openjdk.java.net/jdk/jdk/file/dd5157f363ab/src/java.base/share/classes/java/io/InputStream.java#l166

Reply via email to