Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-449

IOUtils.skip throws an IOException sometimes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Workaround
    • 1.6
    • 1.17
    • None
    • None

    Description

      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 ), 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)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dennisne Dennis New
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: