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

GZipFile#close does not return IO object as MRI does #5197

Closed
pcarlisle opened this issue May 25, 2018 · 2 comments
Closed

GZipFile#close does not return IO object as MRI does #5197

pcarlisle opened this issue May 25, 2018 · 2 comments
Milestone

Comments

@pcarlisle
Copy link

MRI documents (and implements) that #close on GZipFile and subclasses should return the associated IO object. JRuby returns nil.

https://ruby-doc.org/stdlib-2.3.0/libdoc/zlib/rdoc/Zlib/GzipFile.html#method-i-close

https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ext/zlib/RubyGzipFile.java#L252-L255

https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ext/zlib/JZlibRubyGzipWriter.java#L195

In MRI I can do this:

    writer = Zlib::GzipWriter.new(str)
    writer.write(data)
    writer.close.string

which fails in JRuby when trying to call string on nil. I'm running 9.1.16.0 but looks from the source like this has not changed.

@headius
Copy link
Member

headius commented May 25, 2018

Weird feature.

@headius headius added this to the JRuby 9.2.1.0 milestone May 25, 2018
@headius
Copy link
Member

headius commented May 25, 2018

Ok, I think I've fixed this on master. You should see an updated build. There does not appear to be a test for this in either CRuby's suite or in ruby/spec. Perhaps you could add something over at https://github.com/ruby/spec?

pcarlisle added a commit to pcarlisle/puppet that referenced this issue May 31, 2018
JRuby doesn't seem to return the IO object the way MRI does, so don't rely on
that.

jruby/jruby#5197
pcarlisle pushed a commit to pcarlisle/puppet that referenced this issue Jun 1, 2018
JRuby does not return the associated IO object from GZipFile#close as
MRI does. Work around this by asking for the string directly from the IO
object. This is cleaner anyway.

jruby/jruby#5197
pcarlisle pushed a commit to pcarlisle/puppet that referenced this issue Jun 4, 2018
JRuby does not return the associated IO object from GZipFile#close as
MRI does. Work around this by asking for the string directly from the IO
object. This is cleaner anyway.

jruby/jruby#5197
pcarlisle pushed a commit to pcarlisle/puppet that referenced this issue Jun 5, 2018
JRuby does not return the associated IO object from GZipFile#close as
MRI does. Work around this by asking for the string directly from the IO
object. This is cleaner anyway.

jruby/jruby#5197
ccaviness pushed a commit to ccaviness/puppet that referenced this issue Sep 19, 2018
JRuby does not return the associated IO object from GZipFile#close as
MRI does. Work around this by asking for the string directly from the IO
object. This is cleaner anyway.

jruby/jruby#5197
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

2 participants