commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/2] commons-compress git commit: improve error message if an 3rd party library is missing
Date Sat, 30 Dec 2017 11:25:26 GMT
improve error message if an 3rd party library is missing


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/de9665f3
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/de9665f3
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/de9665f3

Branch: refs/heads/master
Commit: de9665f3cbaee56c5089392fbee0a6b81689ed8d
Parents: 6a80b20
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Sat Dec 30 12:24:48 2017 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sat Dec 30 12:24:48 2017 +0100

----------------------------------------------------------------------
 .../compressors/CompressorStreamFactory.java        | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/de9665f3/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
index 5c6063e..e6a4400 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
@@ -201,6 +201,14 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
      */
     public static final String ZSTANDARD = "zstd";
 
+    private static final String YOU_NEED_BROTLI_DEC = youNeed("Google Brotli Dec", "https://github.com/google/brotli/");
+    private static final String YOU_NEED_XZ_JAVA = youNeed("XZ for Java", "https://tukaani.org/xz/java.html");
+    private static final String YOU_NEED_ZSTD_JNI = youNeed("Zstd JNI", "https://github.com/luben/zstd-jni");
+
+    private static String youNeed(String name, String url) {
+        return " In addition to Apache Commons Compress you need the " + name + " library
- see " + url;
+    }
+
     /**
      * Constructs a new sorted map from input stream provider names to provider
      * objects.
@@ -562,28 +570,28 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
 
             if (BROTLI.equalsIgnoreCase(name)) {
                 if (!BrotliUtils.isBrotliCompressionAvailable()) {
-                    throw new CompressorException("Brotli compression is not available.");
+                    throw new CompressorException("Brotli compression is not available."
+ YOU_NEED_BROTLI_DEC);
                 }
                 return new BrotliCompressorInputStream(in);
             }
 
             if (XZ.equalsIgnoreCase(name)) {
                 if (!XZUtils.isXZCompressionAvailable()) {
-                    throw new CompressorException("XZ compression is not available.");
+                    throw new CompressorException("XZ compression is not available." + YOU_NEED_XZ_JAVA);
                 }
                 return new XZCompressorInputStream(in, actualDecompressConcatenated, memoryLimitInKb);
             }
 
             if (ZSTANDARD.equalsIgnoreCase(name)) {
                 if (!ZstdUtils.isZstdCompressionAvailable()) {
-                    throw new CompressorException("Zstandard compression is not available.");
+                    throw new CompressorException("Zstandard compression is not available."
+ YOU_NEED_ZSTD_JNI);
                 }
                 return new ZstdCompressorInputStream(in);
             }
 
             if (LZMA.equalsIgnoreCase(name)) {
                 if (!LZMAUtils.isLZMACompressionAvailable()) {
-                    throw new CompressorException("LZMA compression is not available");
+                    throw new CompressorException("LZMA compression is not available" + YOU_NEED_XZ_JAVA);
                 }
                 return new LZMACompressorInputStream(in, memoryLimitInKb);
             }


Mime
View raw message