Skip to content

In DateTime.jd, some Rational numbers cause RangeError (bignum too big to convert into `long') #5791

@guyboertje

Description

@guyboertje

I am getting this error in my rspec runs in the logstash-input-jdbc.
The Sequel gem (5.22.0) is using tzinfo (2.0.0) to generate DateTime instances when a timezone conversion is being done between the database timezone and the LS application timezone. In some cases a rational number that has very large numerator/denominator combinations is supplied to the jd class method on the JRuby DateTime class. This breaks with a RangeError (bignum too big to convert into `long'). It is easy to reproduce in IRB.

guy at Elastics-MacBook-Pro in ~/elastic/logstash-input-jdbc on jdk11-class-loading*
$ ruby -v
jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b OpenJDK 64-Bit Server VM 11.0.2+9 on 11.0.2+9 +jit [darwin-x86_64]
guy at Elastics-MacBook-Pro in ~/elastic/logstash-input-jdbc on jdk11-class-loading*
$ bundle console
irb(main):001:0> rat = Rational("106143484200006057997/43200000000000")
=> (106143484200006057997/43200000000000)
irb(main):002:0> require 'date'
=> true
irb(main):003:0> dt = DateTime.jd(rat)
Traceback (most recent call last):
       16: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
       15: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/exe/bundle:30:in `block in <main>'
       14: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start'
       13: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
       12: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch'
       11: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
       10: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        9: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        8: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/cli.rb:496:in `console'
        7: from /Users/guy/.rbenv/versions/jruby-9.2.6.0/lib/ruby/gems/shared/gems/bundler-2.0.2/lib/bundler/cli/console.rb:19:in `run'
        6: from org/jruby/RubyKernel.java:1179:in `catch'
        5: from org/jruby/RubyKernel.java:1179:in `catch'
        4: from org/jruby/RubyKernel.java:1411:in `loop'
        3: from org/jruby/RubyKernel.java:1047:in `eval'
        2: from (irb):3:in `evaluate'
        1: from org/jruby/ext/date/RubyDateTime.java:336:in `jd'
RangeError (bignum too big to convert into `long')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions