Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib::GzipWriter.wrap - MRI doesn't close IO object when finish is called, but JRuby does #4249

Open
Bonias opened this issue Oct 26, 2016 · 0 comments

Comments

@Bonias
Copy link

Bonias commented Oct 26, 2016

Environment

  • jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 OpenJDK 64-Bit Server VM 25.91-b14 on 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14 +jit [linux-x86_64]
  • Linux ubuntu 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

MRI Zlib::GzipWriter.wrap documentation says: "If you want to keep the associated IO object open, you may call #finish method in the block." (https://ruby-doc.org/stdlib-2.3.1/libdoc/zlib/rdoc/Zlib/GzipFile.html#method-c-wrap). Here is ruby MRI 2.3.1 example:

require 'zlib'
out = StringIO.new
Zlib::GzipWriter.wrap(out) { |gz| gz.finish }
out.closed? # => false
out.tap(&:rewind).read # => "\u001F\x8B\b\u0000ڸ\u0010X\u0000\u0003\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"

I expected the same behavior with JRuby.

Actual Behavior

require 'zlib'
out = StringIO.new
Zlib::GzipWriter.wrap(out) { |gz| gz.finish }
out.closed? # => true
out.tap(&:rewind).read # raises IOError: not opened for reading
Bonias pushed a commit to Bonias/http that referenced this issue Oct 26, 2016
It seems `Zlib::GzipWriter.wrap` behave differently with JRuby and ruby MRI.
See jruby/jruby#4249.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant