You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dennis New (JIRA)" <ji...@apache.org> on 2018/04/24 01:14:00 UTC

[jira] [Comment Edited] (COMPRESS-449) IOUtils.skip throws an IOException sometimes

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

Dennis New edited comment on COMPRESS-449 at 4/24/18 1:13 AM:
--------------------------------------------------------------

Adding "input.mark(1);", for no particularly good reason :\, at the top of IOUtils.skip before the input.skip call seems to work, I think? If this is reliable, we can test the inputstream if markSupported(), and fallback to input.read if not?


was (Author: dennisne):
Adding "input.mark(1);", for no particularly good reason :\, at the top of IOUtils.skip before the input.skip call seems work, I think? If this is reliable, we can test the inputstream if markSupported(), and fallback to input.read if not?

> IOUtils.skip throws an IOException sometimes
> --------------------------------------------
>
>                 Key: COMPRESS-449
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-449
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Dennis New
>            Priority: Major
>             Fix For: 1.17
>
>
> commons-compress > 1.5 introduced some weird IOUtils.skip bug (it introduced that function in 1.6 in 2013 I think). It exists with all the versions of commons-compress that I tested after 1.5, including 1.6, 1.10. java -version says I'm using openjdk version "1.8.0_151" (IcedTea 3.6.0), and I'm using gnu tar 1.30.
> Basically, is.skip() and IOUtils.skip() are throwing an IOException somewhere somehow. Replacing those functions with is.read(bytearraybufferbla) "fixes" the bug for me.
> I can reproduce the bug by creating a tar file even with a single file in it. Oddly enough, this bug only appears if the file in the tar is greater than 7680 bytes!?. For every possible file size less than or equal to that, it works. For every file size greater than that, (I only tested up to 50,000 bytes :p), it fails. For example:
>   dd if=/dev/zero of=testfile2 bs=1 count=7681
>   tar cf moo.tar testfile2
> Then with the following java test code:
>   import java.io.IOException;
>   import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
>   import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
>   import org.apache.commons.compress.archivers.ArchiveEntry;
>   public class HelloWorld {
>                 public static void main(String[] args) {
>                 try {
>                         TarArchiveInputStream tis = new TarArchiveInputStream (System.in);
>                         ArchiveEntry entry;
>                         while ( (entry=tis.getNextEntry()) != null) {
>                                 System.out.println(entry.getName());
>                         }
>                 } catch (IOException e) {
>                         for (StackTraceElement ste : e.getStackTrace()) {
>                                 System.out.println(ste);
>                         }
>                 }
>         }
>   } 
> Although this works (inputting using that "<" redirection),
>   java -Xbootclasspath/a:commons-compress.jar HelloWorld < moo.tar
> This doesn't work (piping it out of a cat call),
>   cat moo.tar | java -Xbootclasspath/a:commons-compress.jar HelloWorld
> testfile2
> java.io.FileInputStream.skip(Native Method)
> java.io.BufferedInputStream.skip(BufferedInputStream.java:377)
> org.apache.commons.compress.archivers.tar.TarArchiveInputStream.skip(TarArchiveInputStream.java:211)
> org.apache.commons.compress.utils.IOUtils.skip(IOUtils.java:103)
> org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:263)
> org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextEntry(TarArchiveInputStream.java:562)
> HelloWorld.main(HelloWorld.java:11)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)