RFR: 8920687: Deflater.setLevel does not work as expected

Xueming Shen xueming.shen at oracle.com
Sun Sep 15 18:30:23 UTC 2013

Thanks Alan. I dropped the "current" in setLevel. Yes, I would like to 
be explicit about the
deflate invocation here, as the implementation clearly just calls the 
deflate() blindly with
the old level/strategy after the level/strategy changed, regardless 
whether there is really
anything in the buffer or not. So I think it might be good to set the 
expectation clear here.



On 9/14/13 5:24 AM, Alan Bateman wrote:
> On 13/09/2013 20:44, Xueming Shen wrote:
>> Hi,
>> This is change to clarify the java doc to match the existing behavior.
>> If there is a "pending" level/strategy change (via 
>> setLevel/Stragety()) when
>> deflate(...) is invoked, the implementation goes down to zlib's 
>> deflateParams()
>> for deflating operation, which clearly specifies its behavior in 
>> zlib.h as
>> ----------------------------------------------------------------
>>    Dynamically update the compression level and compression 
>> strategy.  The
>>    interpretation of level and strategy is as in deflateInit2. This 
>> can be
>>    used to switch between compression and straight copy of the input 
>> data, or
>>    to switch to a different kind of input data requiring a different 
>> strategy.
>>    If the compression level is changed, the input available so far is
>>    compressed with the old level (and may be flushed); the new level 
>> will take
>>    effect only at the next call of deflate().
>> -----------------------------------------------------------------
>> and its corresponding implementation does exactly that.
> It seems reasonable to have new strategy or level take effect after 
> the available input has been compressed.
> Your proposed wording is okay but I wonder if the word "current" 
> should be dropped from the existing statement in setLevel. You might 
> also be able to get away with a single statement too, something like 
> "If changed, the new compression strategy takes effect after the input 
> available has been compressed (or flushed)". Your wording is okay too 
> if you really need to be explicit about deflate being called.
> -Alan

More information about the core-libs-dev mailing list