6516099: InputStream.skipFully(int k) to skip exactly k bytes
daniel.fuchs at oracle.com
Thu Nov 8 09:50:21 UTC 2018
On 07/11/2018 23:37, Brian Burkhalter wrote:
> 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?)
More information about the core-libs-dev