6516099: InputStream.skipFully(int k) to skip exactly k bytes (original) (raw)
Daniel Fuchs daniel.fuchs at oracle.com
Thu Nov 8 09:50:21 UTC 2018
- Previous message: 6516099: InputStream.skipFully(int k) to skip exactly k bytes
- Next message: 6516099: InputStream.skipFully(int k) to skip exactly k bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Brian,
On 07/11/2018 23:37, Brian Burkhalter wrote:
http://hg.openjdk.java.net/jdk/jdk/file/44f34d2c3243/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatInputStream.java#l99 The above class is not a descendent of InputStream. In any case, as InputStream and all its “direct known subclasses” specify that skip() returns “the actual number of bytes skipped” the foregoing behavior would I think be a bug.
Damn. You're right. My mistake. But if I'm not mistaken again it's called from a class that implements InputStream (that's how I ended up looking at it):
That said, it's altogether possible that the condition on which -1 is returned is dead code and actually never happens. That's hard to tell.
Not sure there's anything that could be done in such cases, except encouraging such subclasses to provide their own implementation of skipNBytes? That’s probably true.
So FWIW my point was that there's nothing that you can really guarantee in InputSteam::skipFully() if a subclass implementation of skip() uses negative number to e.g. signal abnormal conditions (such as EOF?). And I wonder if that should warrant a disclaimer in the API doc of InputStream::skipFully (maybe an @implSpec?)
best regards
-- daniel
Thanks, Brian
- Previous message: 6516099: InputStream.skipFully(int k) to skip exactly k bytes
- Next message: 6516099: InputStream.skipFully(int k) to skip exactly k bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]