JRuby

Giving YAML.load a non-IO object raises a Java error instead of a Ruby error

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.0, JRuby 1.0.1, JRuby 1.0.2, JRuby 1.1b1
  • Fix Version/s: JRuby 1.0.3, JRuby 1.1RC2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    OS X 10.4.10 with Java 5
  • Testcase included:
    yes
  • Number of attachments :
    3

Description

Calling YAML.load with something like an empty hash or array raises a java.lang.IllegalArgumentException with the text "Object: is not a legal argument to this wrapper, cause it doesn't respond to "read"." instead of a Ruby TypeError with the text "instance of IO needed."

A test case is attached; on JRuby 1.0.2 the bad exception is caught and handled by Test::Unit, but on JRuby 1.1b1 it flys all the way to the top and kills the process. The test passes in C Ruby.

Paste of the test case:

=================
require "test/unit"
require "yaml"

class YamlLoadTest < Test::Unit::TestCase
  def test_yaml_load_with_bad_type_raises_typeerror
    [[], {}].each do |not_an_IO_object|
      err = assert_raise(TypeError) do
        YAML.load(not_an_IO_object)
      end
      assert_match("instance of IO needed", err.message)
    end
  end
end
=================
  1. test_yaml_load_with_non_io_object_raises_typeerror.rb
    06/Nov/07 4:51 PM
    0.3 kB
    Matt Fletcher
  2. yaml.jruby-1_0.patch
    09/Nov/07 11:00 PM
    2 kB
    Riley Lynch
  3. yaml.patch
    09/Nov/07 11:00 PM
    2 kB
    Riley Lynch

Activity

Hide
Charles Oliver Nutter added a comment -

Ugly! Fix for 1.0.3 and 1.1.

Show
Charles Oliver Nutter added a comment - Ugly! Fix for 1.0.3 and 1.1.
Hide
Riley Lynch added a comment -

ported syck_parser_assign_io from ext/syck/rubyext.c and applied to YAML::load and YAML::load_documents

Show
Riley Lynch added a comment - ported syck_parser_assign_io from ext/syck/rubyext.c and applied to YAML::load and YAML::load_documents
Hide
Ola Bini added a comment -

Applied. Thanks!

Show
Ola Bini added a comment - Applied. Thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: