JRuby

IO.read and IO.readlines do not take a block

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.5
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

puts IO.read(_FILE_) { "fail" }

should ignore the fail. It does not and instead raises an exception because for some insane reason the block is passed to IO.open.

The attached patch fixes the problem but needs to be cleaned up.

The error message given is this

org.jruby.RubyIO:2801:in `read': java.lang.ClassCastException: org.jruby.RubyString cannot be cast to org.jruby.RubyIO
from org.jruby.RubyIO$s_method_multi$RUBYINVOKER$read:-1:in `call'
from org.jruby.runtime.callsite.CachingCallSite:290:in `cacheAndCall'
from org.jruby.runtime.callsite.CachingCallSite:141:in `callIter'
from read_minus_block_minus_test:1:in `_file_'
from read_minus_block_minus_test:-1:in `_file_'
from read_minus_block_minus_test:-1:in `load'
from org.jruby.Ruby:560:in `runScript'
from org.jruby.Ruby:463:in `runNormally'
from org.jruby.Ruby:337:in `runFromMain'
from org.jruby.Main:214:in `run'
from org.jruby.Main:100:in `run'
from org.jruby.Main:84:in `main'

Activity

Hide
Thomas E Enebo added a comment -

Fixed in commit 8385. Thanks John. An extremely mild mild nit. Don't use tabs in the patches you submit. Please submit more patches

Show
Thomas E Enebo added a comment - Fixed in commit 8385. Thanks John. An extremely mild mild nit. Don't use tabs in the patches you submit. Please submit more patches

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: