Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 83350112398b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d183f8daf790
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 7, 2014

  1. Update RubyIO#ensureYieldClose to match ruby-bug 10153 behavior

    2.2.0 now only swallows "closed stream" errors on IO close, and explicitly
    checks for both respond_to?(:closed?) (and tests it) and respond_to?(:close)
    before attempting to close an IO.
    
    Added ENOSPC helper; the un-swallowing of errors exposed another bug where
    JRuby was throwing an unknown SystemCallError on a full disk due to lack of
    a string check for the ENOSPC IO error.
    cheald committed Nov 7, 2014
    Copy the full SHA
    5a2d482 View commit details
  2. Merge pull request #2141 from cheald/update_io_ensure_close

    Update RubyIO#ensureYieldClose to match ruby-bug 10153 behavior
    headius committed Nov 7, 2014
    Copy the full SHA
    d183f8d View commit details
Showing with 12 additions and 7 deletions.
  1. +7 −4 core/src/main/java/org/jruby/RubyIO.java
  2. +5 −3 core/src/main/java/org/jruby/runtime/Helpers.java
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -1105,11 +1105,14 @@ public static IRubyObject ensureYieldClose(ThreadContext context, IRubyObject po
} finally {
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
try {
port.getMetaClass().finvoke(context, port, "close", IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
if(!(port.respondsTo("closed?") && port.callMethod(context, "closed?").isTrue())) {
if(port.respondsTo("close")) {
port.getMetaClass().finvoke(context, port, "close", IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
}
}
} catch (RaiseException re) {
RubyException rubyEx = re.getException();
if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
// MRI behavior: swallow StandardErorrs
// MRI behavior: Ignore "closed stream"
if (re.getException().message.asJavaString().equals("closed stream")) {
runtime.getGlobalVariables().set("$!", oldExc);
} else {
throw re;
8 changes: 5 additions & 3 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -464,10 +464,12 @@ public static Errno errnoFromException(Throwable t) {
return Errno.ECONNABORTED;
} else if (t.getMessage().equals("Broken pipe")) {
return Errno.EPIPE;
} else if ("Connection reset by peer".equals(t.getMessage())
|| "An existing connection was forcibly closed by the remote host".equals(t.getMessage()) ||
(Platform.IS_WINDOWS && t.getMessage().contains("connection was aborted"))) {
} else if ("Connection reset by peer".equals(errorMessage) ||
"An existing connection was forcibly closed by the remote host".equals(errorMessage) ||
(Platform.IS_WINDOWS && errorMessage.contains("connection was aborted"))) {
return Errno.ECONNRESET;
} else if (errorMessage.equals("No space left on device")) {
return Errno.ENOSPC;
}
}
return null;