RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies (original) (raw)
Dan Xu dan.xu at oracle.com
Wed May 15 18:04:08 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 05/13/2013 06:25 AM, Alan Bateman wrote:
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. Thanks for your review, I have updated wordings in the java doc. The new webrev can be reviewed at http://cr.openjdk.java.net/~dxu/8011136/webrev.01/ <http://cr.openjdk.java.net/%7Edxu/8011136/webrev.01/>.
-Dan
- 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 ]