You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2013/10/04 15:25:45 UTC

svn commit: r1529159 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

Author: bodewig
Date: Fri Oct  4 13:25:44 2013
New Revision: 1529159

URL: http://svn.apache.org/r1529159
Log:
allow format-detection to deal with blocking inputs - COMPRESS-239

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.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=1529159&r1=1529158&r2=1529159&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Oct  4 13:25:44 2013
@@ -106,6 +106,11 @@ The <action> type attribute can be add,u
       <action type="fix" date="2013-09-22" issue="COMPRESS-111">
         Read-only support for LZMA standalone compression has been added.
       </action>
+      <action type="fix" date="2013-10-04" issue="COMPRESS-239">
+        The auto-detecting create*InputStream methods of Archive and
+        CompressorStreamFactory could fail to detect the format of
+        blocking input stream.
+      </action>
     </release>
     <release version="1.5" date="2013-03-14"
              description="Release 1.5">

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=1529159&r1=1529158&r2=1529159&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 Fri Oct  4 13:25:44 2013
@@ -35,6 +35,7 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
 import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * Factory to create Archive[In|Out]putStreams from names or the first bytes of
@@ -274,7 +275,7 @@ public class ArchiveStreamFactory {
         final byte[] signature = new byte[12];
         in.mark(signature.length);
         try {
-            int signatureLength = in.read(signature);
+            int signatureLength = IOUtils.readFully(in, signature);
             in.reset();
             if (ZipArchiveInputStream.matches(signature, signatureLength)) {
                 if (entryEncoding != null) {
@@ -295,7 +296,7 @@ public class ArchiveStreamFactory {
             // Dump needs a bigger buffer to check the signature;
             final byte[] dumpsig = new byte[32];
             in.mark(dumpsig.length);
-            signatureLength = in.read(dumpsig);
+            signatureLength = IOUtils.readFully(in, dumpsig);
             in.reset();
             if (DumpArchiveInputStream.matches(dumpsig, signatureLength)) {
                 return new DumpArchiveInputStream(in);
@@ -304,7 +305,7 @@ public class ArchiveStreamFactory {
             // Tar needs an even bigger buffer to check the signature; read the first block
             final byte[] tarheader = new byte[512];
             in.mark(tarheader.length);
-            signatureLength = in.read(tarheader);
+            signatureLength = IOUtils.readFully(in, tarheader);
             in.reset();
             if (TarArchiveInputStream.matches(tarheader, signatureLength)) {
                 if (entryEncoding != null) {

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=1529159&r1=1529158&r2=1529159&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java Fri Oct  4 13:25:44 2013
@@ -32,6 +32,7 @@ import org.apache.commons.compress.compr
 import org.apache.commons.compress.compressors.xz.XZUtils;
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * <p>Factory to create Compressor[In|Out]putStreams from names. To add other
@@ -133,7 +134,7 @@ public class CompressorStreamFactory {
         final byte[] signature = new byte[12];
         in.mark(signature.length);
         try {
-            int signatureLength = in.read(signature);
+            int signatureLength = IOUtils.readFully(in, signature);
             in.reset();
 
             if (BZip2CompressorInputStream.matches(signature, signatureLength)) {