Code review request "6631046: BufferedInputStream.available() reports negative int on very large inputstream"

Alan Bateman Alan.Bateman at oracle.com
Fri Nov 19 09:16:24 UTC 2010


Mandy Chung wrote:
>  6631046: BufferedInputStream.available() reports negative int on very 
> large inputstream
>
> Webrev at:
> http://cr.openjdk.java.net/~mchung/6631046/webrev.00/
>
> InputStream.available() returns an int. For streams larger than 2GB, 
> the FileInputStream.available() implementation returns 
> Integer.MAX_VALUE which is a reasonable choice.
>
> java.io.BufferedInputStream and java.io.PushbackInputStream maintain a 
> buffer.  The available() method in these 2 classes returns the sum of 
> the number of bytes remaining to be read in the buffer and the result 
> of calling the in.available().   If in.available() returns a large 
> number, the result may overflow and a negative size will be returned.  
> This fixes to handle the overflow case properly.
>
> Thanks
> Mandy
Looks good to me too - thanks for taking this one.

-Alan.



More information about the core-libs-dev mailing list