History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1536
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Ola Bini
Reporter: Matt Fletcher
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

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

Created: 06/Nov/07 04:51 PM   Updated: 22/Dec/07 06:26 AM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.0.0, JRuby 1.0.1, JRuby 1.1b1, JRuby 1.0.2
Fix Version/s: JRuby 1.0.3, JRuby 1.1RC2

Time Tracking:
Not Specified

File Attachments: 1. File test_yaml_load_with_non_io_object_raises_typeerror.rb (0.3 kb)
2. Text File yaml.jruby-1_0.patch (2 kb)
3. Text File yaml.patch (2 kb)

Environment: OS X 10.4.10 with Java 5

Testcase included: yes


 Description  « Hide
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
=================


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter - 07/Nov/07 01:19 AM
Ugly! Fix for 1.0.3 and 1.1.

Riley Lynch - 09/Nov/07 11:00 PM
ported syck_parser_assign_io from ext/syck/rubyext.c and applied to YAML::load and YAML::load_documents

Ola Bini - 29/Nov/07 08:30 AM
Applied. Thanks!