[
https://issues.apache.org/jira/browse/COMPRESS-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13981769#comment-13981769
]
BELUGA BEHR edited comment on COMPRESS-277 at 4/26/14 2:53 PM:
---------------------------------------------------------------
For anyone following this conversation, some of Fabian's comment may seem out
of context because he was addressing my comments. I redacted them as they were
based on bad information I was working off of. My apologies.
was (Author: belugabehr):
Yes! Sorry! I will move to a new ticket! I was confused in that I thought this
had direct changes to the TarInputStream class as I was looking at the wrong
revision. Thanks for bringing these issues to light!
I do admit that the code I suggested was a bit confusing, but I am trying to
help you. IOUtils#skip() from the commons-io package does not call the
stream's skip method, it only calls the stream's read. You may get better
results with the approach I suggested because it allows you to just skip the
'skip' process all together and just pass in a large read buffer allowing for
fewer iterations.
> IOUtils.skip does not work as advertised
> ----------------------------------------
>
> Key: COMPRESS-277
> URL: https://issues.apache.org/jira/browse/COMPRESS-277
> Project: Commons Compress
> Issue Type: Bug
> Affects Versions: 1.8
> Reporter: Fabian Lange
> Fix For: 1.9
>
>
> I am trying to feed a TarInputStream from a CipherInputStream.
> It does not work, because IOUtils.skip() does not adhere to the contract it
> claims in javadoc:
> " * <p>This method will only skip less than the requested number of
> * bytes if the end of the input stream has been reached.</p>"
> However it does:
> long skipped = input.skip(numToSkip);
> if (skipped == 0) {
> break;
> }
> And the input stream javadoc says:
> " * This may result from any of a number of conditions; reaching end of
> file
> * before <code>n</code> bytes have been skipped is only one possibility."
> In the case of CipherInputStream, it stops at the end of each byte buffer.
> If you check the IOUtils from colleagues at commons-io, they have considered
> this case in IOUtils.skip() where they use a read to skip through the stream.
> An optimized version could combine trying to skip, then read then trying to
> skip again.
--
This message was sent by Atlassian JIRA
(v6.2#6252)