Skip to content

Clarification on default JdkZlibEncoder compression level #15212

@daschl

Description

@daschl

In JdkZlibEncoder, the javadoc specifies:

     * @param compressionLevel
     *        {@code 1} yields the fastest compression and {@code 9} yields the
     *        best compression.  {@code 0} means no compression.  The default
     *        compression level is {@code 6}.

Now this is true in case the overload with no compression level is used:

    /**
     * Creates a new zlib encoder with the default compression level ({@code 6})
     * and the specified wrapper.
     *
     * @throws CompressionException if failed to initialize zlib
     */
    public JdkZlibEncoder(ZlibWrapper wrapper) {
        this(wrapper, 6);
    }

But if you look into the java.util.zip.Deflater that gets created in the constructor, it actually specifies:

    /**
     * Default compression level.
     */
    public static final int DEFAULT_COMPRESSION = -1;

Is there any reason why the netty default compression level deviates from the underlying Deflater default compression level?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions