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

Comments

Projects
None yet
2 participants
@pcarlisle
Copy link

pcarlisle commented May 25, 2018

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

This comment has been minimized.

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 headius closed this in e873dd5 May 25, 2018

@headius

This comment has been minimized.

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

(PUP-1952) Don't rely on return value of GzipFile#close
JRuby doesn't seem to return the IO object the way MRI does, so don't rely on
that.

jruby/jruby#5197

pcarlisle added a commit to pcarlisle/puppet that referenced this issue Jun 1, 2018

(PUP-1952) Fix GzipWriter close call for jruby
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 added a commit to pcarlisle/puppet that referenced this issue Jun 4, 2018

(PUP-1952) Fix GzipWriter close call for jruby
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 added a commit to pcarlisle/puppet that referenced this issue Jun 5, 2018

(PUP-1952) Fix GzipWriter close call for jruby
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 added a commit to ccaviness/puppet that referenced this issue Sep 19, 2018

(PUP-1952) Fix GzipWriter close call for jruby
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
You can’t perform that action at this time.