[
https://issues.apache.org/jira/browse/COMPRESS-699?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17955212#comment-17955212
]
Gary D. Gregory commented on COMPRESS-699:
------------------------------------------
Hello [~mxnguyen]
Thank you for your report.
How was this TAR file created?
> 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
> Priority: Major
> Attachments: 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)