-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment
$ jruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d OpenJDK 64-Bit Server VM 25.66-b17 on 1.8.0_66-internal-b17 +indy +jit [linux-amd64]
$ uname -a
Linux x220 4.2.0-35-generic #40-Ubuntu SMP Tue Mar 15 22:15:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Expected Behavior
When calling Time.parse in MRI, it coerces the object into a String. For instance, in the syslog-parser code, it passes an object that can be coerced into a string and expects it to work.
Here's a simple repro case:
class Foo
def to_str
puts "coerced"
Time.now.to_s
end
end
require 'time'
puts Time.parse(Foo.new)$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
$ ruby test_time.rb
coerced
2016-04-19 14:32:42 -0500Actual Behavior
In JRuby 9.0.5.0, it doesn't coerce the argument passed in.
$ jruby test_time.rb
NoMethodError: undefined method `gsub!' for #<Foo:0x305fd85d>
_parse at /home/hone/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/date/format.rb:841
parse at /home/hone/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/time.rb:361
<top> at test_time.rb:9/cc @jkutner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels