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/18 01:48:00 UTC
[jira] [Created] (COMPRESS-448) IOUtils.skip is throwing an
IOException somewhere sometimes
Dennis New created COMPRESS-448:
-----------------------------------
Summary: IOUtils.skip is throwing an IOException somewhere sometimes
Key: COMPRESS-448
URL: https://issues.apache.org/jira/browse/COMPRESS-448
Project: Commons Compress
Issue Type: Bug
Affects Versions: 1.6
Reporter: Dennis New
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)