RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies (original) (raw)
Alan Bateman Alan.Bateman at oracle.com
Mon May 13 13:25:03 UTC 2013
- Previous message: RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies
- Next message: RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/05/2013 22:20, Dan Xu wrote:
Hi,
The FileInputStream.available() method can return a negative value when the file position is beyond the endof afile. This is an unspecified behaviour that has the potential to break applications that expect available to return a value of 0 or greater. The FileInputStream.skip(long) method allows a negative value as its parameter. This conflicts with the specifications of InputStream and FileInputStream classes. They are both long standing behaviours. In the fix, available() has been changed to only return 0 or positive values. And for the skip(long) method, due to the compatibility concern, its behaviour will not be changed. Instead, the related java specs are going to be changed to describe its current behaviour. bug: http://bugs.sun.com/viewbug.do?bugid=8011136 webrev: http://cr.openjdk.java.net/~dxu/8011136/webrev.00/ Thanks for your review! -Dan Thanks for following up on this one. Overall I agree with the approach, it specifies skip to match long standing behavior and fixes available to not return negative values.
Just on wording, it might be better if the new statement in InputStream.skip didn't start with "But". How about "Subclasses may ..." as this would be consistent with exiting wording in this class.
For FileInputStream then the statement on how "available" behaves should probably move to the available javadoc. Something like "Returns 0 when the file position is beyond EOF" should be fine.
-Alan.
- Previous message: RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies
- Next message: RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]