yakovsh commented on code in PR #433:
URL: https://github.com/apache/commons-compress/pull/433#discussion_r1389747845


##########
src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java:
##########
@@ -522,6 +547,27 @@ public CompressorInputStream 
createCompressorInputStream(final InputStream in) t
         return createCompressorInputStream(detect(in), in);
     }
 
+    /**
+     * Create a compressor input stream from an input stream, auto-detecting 
the
+     * compressor type from the first few bytes of the stream while limiting 
the detected type
+     * to the provided set of compressor names. The InputStream must support 
marks, like BufferedInputStream.
+     *
+     * @param in
+     *            the input stream
+     * @param compressorNames
+     *            compressor names to limit autodetection
+     * @return the compressor input stream
+     * @throws CompressorException
+     *             if the autodetected compressor is not in the provided set 
of compressor names
+     * @throws IllegalArgumentException
+     *             if the stream is null or does not support mark
+     * @since 1.25

Review Comment:
   I will change it



##########
src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java:
##########
@@ -226,10 +227,32 @@ private static Iterable<CompressorStreamProvider> 
archiveStreamProviderIterable(
      * @since 1.14
      */
     public static String detect(final InputStream inputStream) throws 
CompressorException {
+        final Set<String> defaultCompressorNamesForDetection =
+                Sets.newHashSet(BZIP2, GZIP, PACK200, SNAPPY_FRAMED, Z, 
DEFLATE, XZ, LZMA, LZ4_FRAMED, ZSTANDARD);
+        return detect(inputStream, defaultCompressorNamesForDetection);
+    }
+
+    /**
+     * Try to detect the type of compressor stream while limiting the type to 
the provided set of compressor names.
+     *
+     * @param inputStream input stream
+     * @param compressorNames compressor names to limit autodetection
+     * @return type of compressor stream detected
+     * @throws CompressorException if no compressor stream type was detected
+     *                             or if something else went wrong
+     * @throws IllegalArgumentException if stream is null or does not support 
mark
+     *
+     * @since 1.24

Review Comment:
   got it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to