Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IO#open with block should swallow StandardErrors during close.

This will fix some of the new rubyspecs.


git-svn-id: http://svn.codehaus.org/jruby/branches/headius_io2@5825 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 1d83a6ad6c3743337761b6cc25c4ea2228f13342 1 parent 5b14078
@vvs vvs authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/org/jruby/RubyIO.java
View
12 src/org/jruby/RubyIO.java
@@ -61,6 +61,7 @@
import org.jruby.anno.JRubyMethod;
import org.jruby.common.IRubyWarnings.ID;
+import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.MethodIndex;
@@ -855,7 +856,16 @@ public static IRubyObject open(IRubyObject recv, IRubyObject[] args, Block block
return block.yield(runtime.getCurrentContext(), io);
} finally {
if (io.openFile.isOpen()) {
- io.close();
+ try {
+ io.close();
+ } catch (RaiseException re) {
+ RubyException rubyEx = re.getException();
+ if (rubyEx.kind_of_p(runtime.getStandardError()).isTrue()) {
+ // MRI behavior: swallow StandardErorrs
+ } else {
+ throw re;
+ }
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.