You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/11 14:25:14 UTC

[jira] [Commented] (COMPRESS-277) IOUtils.skip does not work as advertised

    [ https://issues.apache.org/jira/browse/COMPRESS-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13966452#comment-13966452 ] 

Emmanuel Bourg commented on COMPRESS-277:
-----------------------------------------

Thank you Fabian, note that IOUtils is only used by commons-compress to avoid a dependency on commons-io. As such it's more an internal class than something supposed to be used by anyone. You should use the version from commons-io instead.

> 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
>            Reporter: Fabian Lange
>
> 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)