JRuby

Zlib::Deflate doesn't appear to deflate

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.2
  • Component/s: Extensions
  • Labels:
    None
  • Number of attachments :
    0

Description

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: ""

Activity

Hide
Charles Oliver Nutter added a comment -

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.

Show
Charles Oliver Nutter added a comment - 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.
Hide
Charles Oliver Nutter added a comment -

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+.

Show
Charles Oliver Nutter added a comment - 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+.
Hide
Charles Oliver Nutter added a comment -

Fixed in r9058.

Show
Charles Oliver Nutter added a comment - Fixed in r9058.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: