commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1084567 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Date Wed, 23 Mar 2011 12:50:15 GMT
Author: sebb
Date: Wed Mar 23 12:50:15 2011
New Revision: 1084567

URL: http://svn.apache.org/viewvc?rev=1084567&view=rev
Log:
COMPRESS-117 Certain tar files not recognised by ArchiveStreamFactory
Check if first entry can be read as a Tar entry

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1084567&r1=1084566&r2=1084567&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Wed Mar 23 12:50:15 2011
@@ -45,6 +45,9 @@ The <action> type attribute can be add,u
   </properties>
   <body>
     <release version="1.2" date="as in SVN" description="Release 1.2">
+      <action issue="COMPRESS-117" type="update" date="2011-03-23">
+        Certain tar files not recognised by ArchiveStreamFactory.
+      </action> 
       <action issue="COMPRESS-125" type="fix" date="2011-03-23">
         BZip2CompressorInputStream throws IOException if underlying stream returns available()
== 0.
         Removed the check.

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1084567&r1=1084566&r2=1084567&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Wed Mar 23 12:50:15 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.commons.compress.archivers;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -216,6 +217,14 @@ public class ArchiveStreamFactory {
             if (TarArchiveInputStream.matches(tarheader, signatureLength)) {
                 return new TarArchiveInputStream(in);
             }
+            // COMPRESS-117 - improve auto-recognition
+            try {
+                TarArchiveInputStream tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));
+                tais.getNextEntry();
+                return new TarArchiveInputStream(in);
+            } catch (Exception e) { // can generate IllegalArgumentException as well as IOException
+                // ignored
+            }
         } catch (IOException e) {
             throw new ArchiveException("Could not use reset and mark operations.", e);
         }



Mime
View raw message