IO.read not always closes the file ---------------------------------- Key: JRUBY-4418 URL: http://jira.codehaus.org/browse/JRUBY-4418 Project: JRuby Issue Type: Bug Components: Core Classes/Modules, RubySpec Affects Versions: JRuby 1.4 Reporter: Vladimir Sizikov Assignee: Vladimir Sizikov Fix For: JRuby 1.5
Consider the following: {code} File.open('test_file', 'wb') { |f| f.write 'abc' } IO.read('test_file', 0, -1) rescue nil File.unlink('test_file') {code} On Windows the unlink call fails with: {noformat}`unlink': Permission denied - test_file (Errno::EACCES){noformat} This is due to fact that IO.read, invoked with invalid offset parameter does not close the opened file. But the documentation clearly states that: "read ensures the file is closed before returning." This causes two RubySpec failures for IO.read: {noformat} mspec -t r core\io\read_spec.rb ruby 1.9.2dev (2009-11-12 trunk 25723) [i386-mingw32] ..........E..E..................E. 1) An exception occurred during: after :each IO.read raises an Errno::EINVAL when not passed a valid offset ERROR Errno::EACCES: Permission denied - D:/work/jruby-dev/rubyspec.git/rubyspec_temp/io_read.txt D:/work/jruby-dev/rubyspec.git/core/io/read_spec.rb:13:in `block (2 levels) in <top (required)>' D:/work/jruby-dev/rubyspec.git/core/io/read_spec.rb:5:in `<top (required)>' D:/work/jruby-dev/mspec.git/bin/mspec-run:8:in `<main>' 2) An exception occurred during: after :each IO#read can be read from consecutively ERROR Errno::EACCES: Permission denied - D:/work/jruby-dev/rubyspec.git/rubyspec_temp/io_read.txt D:/work/jruby-dev/rubyspec.git/core/io/read_spec.rb:100:in `block (2 levels) in <top (required)>' D:/work/jruby-dev/rubyspec.git/core/io/read_spec.rb:88:in `<top (required)>' D:/work/jruby-dev/mspec.git/bin/mspec-run:8:in `<main>' {noformat} Will fix. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email