Skip to content

JZlibRubyGzipWriter doesn't handle nil arguments gracefully #1088

@gaurish

Description

@gaurish

this works on MRI

> Zlib::GzipWriter.new('works ONLY on MRI', nil, nil)
#<Zlib::GzipWriter:0xa42755c>

but blows up on JRuby

> Zlib::GzipWriter.new('works ONLY on MRI', nil, nil)
TypeError: no implicit conversion from nil to integer
    from org/jruby/ext/zlib/JZlibRubyGzipWriter.java:108:in `initialize'
    from org/jruby/ext/zlib/JZlibRubyGzipWriter.java:49:in `new'
    from (irb):2:in `evaluate'
    from org/jruby/RubyKernel.java:1121:in `eval'
    from org/jruby/RubyKernel.java:1517:in `loop'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from /home/gaurish/code/repo/jruby/bin/jirb:13:in `(root)'

Why?
This is needed to get this failing test passing in rails. Also, I think its always a good practice to check for nil values & discard them instead of throwing an exception.

Tested on jruby-head

#11700

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions