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

David Holmes David.Holmes at oracle.com
Thu Nov 18 23:06:36 UTC 2010


Hi Mandy,

Looks good to me.

David

Mandy Chung said the following on 11/19/10 08:34:
>  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



More information about the core-libs-dev mailing list