Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ruby-2.3
Browse files Browse the repository at this point in the history
Conflicts:
	core/src/main/java/org/jruby/RubyKernel.java
	core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
	core/src/main/java/org/jruby/parser/RubyParser.java
	core/src/main/java/org/jruby/util/io/EncodingUtils.java
headius committed Dec 22, 2015
2 parents e5e63be + 876c048 commit 7339b55
Showing 152 changed files with 1,900 additions and 1,686 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
*.versionsBackup
*.zip
*~
*.tokens

.DS_Store
.debug.properties
61 changes: 32 additions & 29 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3959,40 +3959,43 @@ public RaiseException newStandardError(String message) {
* 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?
*/
public RaiseException newIOErrorFromException(IOException e) {
if (e instanceof ClosedChannelException || "Bad file descriptor".equals(e.getMessage())) {
throw newErrnoEBADFError();
}

// TODO: this is kinda gross
if(e.getMessage() != null) {
String errorMessage = e.getMessage();
public RaiseException newIOErrorFromException(final IOException ex) {
final String errorMessage = ex.getMessage();
if ( errorMessage != null ) {
// 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)) {
return newIOError(e.getMessage());
} else if ("An established connection was aborted by the software in your host machine".equals(errorMessage)) {
return newErrnoECONNABORTEDError();
} else if (e.getMessage().equals("Broken pipe")) {
return newErrnoEPIPEError();
} else if ("Connection reset by peer".equals(e.getMessage())
|| "An existing connection was forcibly closed by the remote host".equals(e.getMessage()) ||
(Platform.IS_WINDOWS && e.getMessage().contains("connection was aborted"))) {
return newErrnoECONNRESETError();
} else if ("Too many levels of symbolic links".equals(e.getMessage())) {
return newErrnoELOOPError();
} else if ("Too many open files".equals(e.getMessage())) {
return newErrnoEMFILEError();
} else if ("Too many open files in system".equals(e.getMessage())) {
return newErrnoENFILEError();
} else if ("Network is unreachable".equals(e.getMessage())) {
return newErrnoENETUNREACHError();
switch ( errorMessage ) {
case "Bad file descriptor" :
if ( ex instanceof ClosedChannelException ) throw newErrnoEBADFError();
break;
case "File not open" :
return newIOError(errorMessage);
case "An established connection was aborted by the software in your host machine" :
return newErrnoECONNABORTEDError();
case "Broken pipe" :
return newErrnoEPIPEError();
case "Connection reset by peer" :
case "An existing connection was forcibly closed by the remote host" :
return newErrnoECONNRESETError();
case "Too many levels of symbolic links" :
return newErrnoELOOPError();
case "Too many open files" :
return newErrnoEMFILEError();
case "Too many open files in system" :
return newErrnoENFILEError();
case "Network is unreachable" :
return newErrnoENETUNREACHError();
default :
if ( Platform.IS_WINDOWS ) {
if ( errorMessage.contains("connection was aborted") ) {
return newErrnoECONNRESETError();
}
}
}
return newRaiseException(getIOError(), e.getMessage());
} else {
return newRaiseException(getIOError(), "IO Error");
return newRaiseException(getIOError(), errorMessage);
}
return newRaiseException(getIOError(), "IO Error");
}

public RaiseException newTypeError(IRubyObject receivedObject, RubyClass expectedType) {
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -1209,6 +1209,7 @@ public static IRubyObject max_by(ThreadContext context, IRubyObject self, final

@JRubyMethod
public static IRubyObject max_by(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) {
if (arg == context.nil) return singleExtentBy(context, self, "max", SORT_MAX, block);
// TODO: Replace with an implementation (quickselect, etc) which requires O(k) memory rather than O(n) memory
RubyArray sorted = (RubyArray)sort_by(context, self, block);
return ((RubyArray) sorted.last(arg)).reverse();
@@ -1221,6 +1222,7 @@ public static IRubyObject min_by(ThreadContext context, IRubyObject self, final

@JRubyMethod
public static IRubyObject min_by(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) {
if (arg == context.nil) return singleExtentBy(context, self, "min", SORT_MIN, block);
// TODO: Replace with an implementation (quickselect, etc) which requires O(k) memory rather than O(n) memory
RubyArray sorted = (RubyArray)sort_by(context, self, block);
return sorted.first(arg);
Loading

0 comments on commit 7339b55

Please sign in to comment.