RFR: 4452735: Add GZIPOutputStream constructor to specify Deflater

Chen Liang liach at openjdk.org
Mon Nov 25 17:10:21 UTC 2024


On Wed, 17 Jul 2024 21:07:23 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> The class `GZIPOutputStream` extends `DeflaterOutputStream`, which is logical because the GZIP encoding is based on ZLIB "deflate" encoding.
> 
> However, while `DeflaterOutputStream` provides constructors that take a custom `Deflater` argument supplied by the caller, `GZIPOutputStream` has no such constructors.
> 
> As a result, it's not possible to do entirely reasonable customization, such as configuring a `GZIPOutputStream` for a non-default compression level.
> 
> This change adds a new `GZIPOutputStream` constructor that accepts a custom `Deflater`, and also adds a basic unit test for it and all of the other `GZIPOutputStream` constructors, based on the existing test `BasicGZIPInputStreamTest.java` which does the same thing for `GZIPInputStream`.

src/java.base/share/classes/java/util/zip/GZIPOutputStream.java line 78:

> 76:      * @throws    IllegalArgumentException if {@code size <= 0}
> 77:      *
> 78:      * @since 24

Suggestion:

     * @since 25

test/jdk/java/util/zip/GZIP/BasicGZIPOutputStreamTest.java line 45:

> 43: public class BasicGZIPOutputStreamTest {
> 44: 
> 45: ////// Verify that the GZIPOutputStream constructors throw the expected NullPointerException

Triple-slash makes a markdown comment. Also we usually indent the comments. I recommend converting them to javadoc or comment on the `@ParameterizedTest` methods.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20226#discussion_r1856970723
PR Review Comment: https://git.openjdk.org/jdk/pull/20226#discussion_r1856972963


More information about the core-libs-dev mailing list