Issue Details (XML | Word | Printable)

Key: JRUBY-2772
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Charles Oliver Nutter
Reporter: Charles Oliver Nutter
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

Zlib::Deflate doesn't appear to deflate

Created: 09/Jul/08 01:50 PM   Updated: 21/Mar/09 01:14 PM
Component/s: Extensions
Affects Version/s: None
Fix Version/s: JRuby 1.2

Time Tracking:
Not Specified


 Description  « Hide
Based on the script here: http://redmine.ruby-lang.org/issues/show/239

The output doesn't appear right because it seems like deflate.finish is just returning an empty string:

deflated: ""
inflated: ""


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter added a comment - 11/Jul/08 09:35 PM
Here's the contents of the script:
require 'zlib'

data = ('a'..'z').to_a.join
d = Zlib::Deflate.new Zlib::NO_COMPRESSION, Zlib::MAX_WBITS,
                      Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY
d << data.slice!(0, 10)
d.params Zlib::BEST_COMPRESSION, Zlib::DEFAULT_STRATEGY
d << data

deflated = d.finish

puts "deflated: %p" % deflated

inflated = Zlib::Inflate.inflate deflated

puts "inflated: %p" % inflated

It appears that it's the modification of compression params in the middle causing problems. When that line is commented out, deflate works correctly.


Charles Oliver Nutter added a comment - 11/Jul/08 10:21 PM
Yes, the current implementation buffers the incoming bytes rather than immediately feeding them to the java.util.zip.Deflate class. This means that at a minimum the compression change halfway through is not observed, and with the current implementation it appears to break deflation entirely. Probably not going to get a fix in for 1.1.3, so I'm bumping to 1.1+.

Charles Oliver Nutter added a comment - 07/Feb/09 02:36 PM
Fixed in r9058.