osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [compress][io] Avoid InputStream#skip?


On 2018-04-23, sebb wrote:

> On 23 April 2018 at 19:45, Stefan Bodewig <bodewig@xxxxxxxxxx> wrote:
>> On 2018-04-22, Gary Gregory wrote:

>>> We should at the very least document all of this carefully.

>> commons-io's IOUtils already quite clearly states it is using read and
>> not using skip at all.

>>> My gut reaction is that an API called skip should call skip internally.
>>> Doing anything else clever as you point out has performance implications
>>> and might violate the principle of least surprise.

>> Unfortunately I don't see any clean way to use skip at all.

> If skip only fails when trying to read a new buffer, it might be
> possible to get the file position before calling skip.
> This assumes that the failure does not occur after reading any further.

I've tried to implement something like this, see the COMPRESS-449
branch. Unfortunately it breaks the assumption that I can mark() the
stream before calling skip() and reset() afterwards - see
Pack200TestCase#testInputStreamMethods()

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxx