commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1453941 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
Date Thu, 07 Mar 2013 16:16:32 GMT
Author: bodewig
Date: Thu Mar  7 16:16:32 2013
New Revision: 1453941

URL: http://svn.apache.org/r1453941
Log:
COMPRESS-221 make XZ for Jaca truely optional for CompressorStreamFactory, based on patch
description by Matt Quigley

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.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=1453941&r1=1453940&r2=1453941&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Mar  7 16:16:32 2013
@@ -164,6 +164,10 @@ The <action> type attribute can be add,u
           Fixed a potential ArrayIndexOutOfBoundsException when
           reading STORED entries from ZipArchiveInputStream.
         </action>
+        <action type="fix" date="2013-03-07" issue="COMPRESS-221">
+          CompressorStreamFactory can now be used without XZ for Java
+          being available.
+        </action>
     </release>
     <release version="1.4.1" date="2012-05-23"
              description="Release 1.4.1">

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=1453941&r1=1453940&r2=1453941&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
Thu Mar  7 16:16:32 2013
@@ -28,6 +28,7 @@ import org.apache.commons.compress.compr
 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
+import org.apache.commons.compress.compressors.xz.XZUtils;
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
 
@@ -117,7 +118,8 @@ public class CompressorStreamFactory {
                 return new GzipCompressorInputStream(in);
             }
 
-            if (XZCompressorInputStream.matches(signature, signatureLength)) {
+            if (XZUtils.isXZCompressionAvailable() &&
+                XZCompressorInputStream.matches(signature, signatureLength)) {
                 return new XZCompressorInputStream(in);
             }
 

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java?rev=1453941&r1=1453940&r2=1453941&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
Thu Mar  7 16:16:32 2013
@@ -44,6 +44,19 @@ public class XZUtils {
     }
 
     /**
+     * Are the classes required to support XZ compression available?
+     * @since Commons Compress 1.5
+     */
+    public static boolean isXZCompressionAvailable() {
+        try {
+            XZCompressorInputStream.matches(null, 0);
+            return true;
+        } catch (NoClassDefFoundError error) {
+            return false;
+        }
+    }
+
+    /**
      * Detects common xz suffixes in the given filename.
      *
      * @param filename name of a file



Mime
View raw message