You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarification on default JdkZlibEncoder compression level #15212
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 */publicJdkZlibEncoder(ZlibWrapperwrapper) {
this(wrapper, 6);
}
But if you look into the java.util.zip.Deflater that gets created in the constructor, it actually specifies:
One more comment on this. If we want to allow the default compression level of the Deflater to set, we also need to change the constructor of the JdkZlibEncoder since right now it checks a range from 0 to 9.
I don't remember the exact detail since it was written long time ago, but according to zlib manual:
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6).
Another more conservative approach we could as a first step is to allow at least -1 as a value being passed in? than it is backwards compatible and users who want to set -1 can do so.
Activity
daschl commentedon May 20, 2025
One more comment on this. If we want to allow the default compression level of the
Deflaterto set, we also need to change the constructor of theJdkZlibEncodersince right now it checks a range from0to9.normanmaurer commentedon May 20, 2025
@daschl honestly I can't remember why we used this value. Maybe @trustin remembers ?
trustin commentedon May 20, 2025
I don't remember the exact detail since it was written long time ago, but according to zlib manual:
trustin commentedon May 20, 2025
I think we can make a change so it accepts
-1as the default.daschl commentedon May 20, 2025
Another more conservative approach we could as a first step is to allow at least
-1as a value being passed in? than it is backwards compatible and users who want to set -1 can do so.normanmaurer commentedon May 20, 2025
@daschl sounds like a plan... Please send over a PR
Make JdkZlibEncoder accept Deflater.DEFAULT_COMPRESSION as level
Make JdkZlibEncoder accept Deflater.DEFAULT_COMPRESSION as level (#15217
Make JdkZlibEncoder accept Deflater.DEFAULT_COMPRESSION as level (#15217
Make JdkZlibEncoder accept Deflater.DEFAULT_COMPRESSION as level (#15… (