[
https://issues.apache.org/jira/browse/COMPRESS-699?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17955293#comment-17955293
]
Michael Nguyen commented on COMPRESS-699:
-----------------------------------------
Thanks for the fast response! The fix worked for several tars I tested it with,
but for one tar from pub repo, it still unfortunately throws the
ArchiveException.
I've attached the example below. It throws the exception when passed through
detect on the master branch but returns tar on 1.26.0.
[^flutter_awesome_buttons-0.1.0.tar]
> ArchiveStreamFactory.detect(inputStream) ArchiveException for TAR regression
> ----------------------------------------------------------------------------
>
> Key: COMPRESS-699
> URL: https://issues.apache.org/jira/browse/COMPRESS-699
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.26.1, 1.26.2, 1.27.0, 1.27.1
> Reporter: Michael Nguyen
> Assignee: Gary D. Gregory
> Priority: Major
> Fix For: 1.28.0
>
> Attachments: flutter_awesome_buttons-0.1.0.tar,
> icure_medical_device_dart_sdk-1.2.10.tar
>
>
> Prior to version 1.26.1, calling ArchiveStreamFactory.detect on the attached
> TAR file identifies it as a TAR file properly but now throws an
> ArchiveException. It seems related to the changes to address COMPRESS-644,
> specifically the the entry.getSize() > 0 check on line 288 of
> ArchiveStreamFactory.java.
> Below is some sample code to reproduce the error (the below code runs without
> errors when tested on 1.26.0):
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory;
> import org.apache.commons.io.FileUtils;
> import org.junit.Test;
> import java.io.BufferedInputStream;
> import java.io.File;
> import java.nio.file.Files;
> import static
> com.sonatype.data.testing.utils.ResourcesUtils.getResourceAsInputStream;
> public class TarArchiveTest
> {
> @Test
> public void testTarArchive() throws Exception {
> String fileToTest = "icure_medical_device_dart_sdk-1.2.10.tar";
> File sourceFile = new File(fileToTest);
> FileUtils.copyInputStreamToFile(getResourceAsInputStream(fileToTest),
> sourceFile);
> BufferedInputStream fileInputStream = new
> BufferedInputStream(Files.newInputStream(sourceFile.toPath()));
> System.out.println("Detected archive type: " +
> ArchiveStreamFactory.detect(fileInputStream));
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)