[jruby~main:6e8d0d52] JRUBY-4685: Installing gems in JRuby on Windows fails most of the time.
- From: nicksieger@kenai.com
- To: commits@jruby.kenai.com
- Subject: [jruby~main:6e8d0d52] JRUBY-4685: Installing gems in JRuby on Windows fails most of the time.
- Date: Wed, 31 Mar 2010 19:01:41 +0000
Project: jruby
Repository: main
Revision: 6e8d0d52375859371cdbfb8c3ed99a29765dfdd7
Author: nicksieger
Date: 2010-03-31 19:01:18 UTC
Link:
Log Message:
------------
JRUBY-4685: Installing gems in JRuby on Windows fails most of the time.
Revisions:
----------
6e8d0d52375859371cdbfb8c3ed99a29765dfdd7
Modified Paths:
---------------
src/org/jruby/Ruby.java
src/org/jruby/RubyIO.java
Diffs:
------
diff --git a/src/org/jruby/Ruby.java b/src/org/jruby/Ruby.java
index 35c737a..6e5bac9 100644
--- a/src/org/jruby/Ruby.java
+++ b/src/org/jruby/Ruby.java
@@ -2969,6 +2969,11 @@ public final class Ruby {
return newRaiseException(getErrno().fastGetClass("EPIPE"), "Broken
pipe");
}
+ public RaiseException newErrnoECONNABORTEDError() {
+ return newRaiseException(getErrno().fastGetClass("ECONNABORTED"),
+ "An established connection was aborted by the software in
your host machine");
+ }
+
public RaiseException newErrnoECONNREFUSEDError() {
return newRaiseException(getErrno().fastGetClass("ECONNREFUSED"),
"Connection refused");
}
diff --git a/src/org/jruby/RubyIO.java b/src/org/jruby/RubyIO.java
index ec3918d..cc79801 100644
--- a/src/org/jruby/RubyIO.java
+++ b/src/org/jruby/RubyIO.java
@@ -2591,17 +2591,32 @@ public class RubyIO extends RubyObject {
} catch (EOFException e) {
throw getRuntime().newEOFError();
} catch (IOException e) {
- // All errors to sysread should be SystemCallErrors, but on a
closed stream
- // Ruby returns an IOError. Java throws same exception for all
errors so
- // we resort to this hack...
- if ("File not open".equals(e.getMessage())) {
- throw getRuntime().newIOError(e.getMessage());
- }
- throw getRuntime().newSystemCallError(e.getMessage());
+ synthesizeSystemCallError(e);
+ return null;
} finally {
context.getThread().afterBlockingCall();
}
}
+
+ /**
+ * Java does not give us enough information for specific error conditions
+ * so we are reduced to divining them through string matches...
+ */
+ // TODO: Should ECONNABORTED get thrown earlier in the descriptor itself
or is it ok to handle this late?
+ // TODO: Should we include this into Errno code somewhere do we can use
this from other places as well?
+ private void synthesizeSystemCallError(IOException e) {
+ String errorMessage = e.getMessage();
+ // All errors to sysread should be SystemCallErrors, but on a closed
stream
+ // Ruby returns an IOError. Java throws same exception for all
errors so
+ // we resort to this hack...
+ if ("File not open".equals(errorMessage)) {
+ throw getRuntime().newIOError(e.getMessage());
+ } else if ("An established connection was aborted by the software in
your host machine".equals(errorMessage)) {
+ throw getRuntime().newErrnoECONNABORTEDError();
+ }
+
+ throw getRuntime().newSystemCallError(e.getMessage());
+ }
public IRubyObject read(IRubyObject[] args) {
ThreadContext context = getRuntime().getCurrentContext();
|
[jruby~main:6e8d0d52] JRUBY-4685: Installing gems in JRuby on Windows fails most of the time. |
nicksieger | 03/31/2010 |





