Skip to content

Commit

Permalink
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -281,6 +281,8 @@ public static Errno errnoFromException(Throwable t) {
case "Too many open files" : return Errno.EMFILE;
case "Message too large" : // Alpine Linux
case "Message too long" : return Errno.EMSGSIZE;
case "Is a directory":
return Errno.EISDIR;
}
if (Platform.IS_WINDOWS && errorMessage.contains("connection was aborted")) return Errno.ECONNRESET;
}
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/util/io/OpenFile.java
Original file line number Diff line number Diff line change
@@ -1399,6 +1399,12 @@ boolean waitReadable(ThreadContext context, ChannelFD fd) {
return false;
}

if (posix.errno != null && posix.errno != Errno.EAGAIN
&& posix.errno != Errno.EWOULDBLOCK && posix.errno != Errno.EINTR) {
// Encountered a permanent error. Don't read again.
return false;
}

if (fd.chSelect != null) {
unlock();
try {
15 changes: 15 additions & 0 deletions test/jruby/test_io.rb
Original file line number Diff line number Diff line change
@@ -384,6 +384,21 @@ def test_read_ignores_blocks
assert(a)
end

unless WINDOWS
# On Windows an error is raised when opening a directory instead of when reading.
def test_read_directory
File.open('.', 'r') do |f|
assert_raise(Errno::EISDIR) { f.read }
end
end

def test_gets_directory
File.open('.', 'r') do |f|
assert_raise(Errno::EISDIR) { f.gets }
end
end
end

if (WINDOWS)
#JRUBY-2158
def test_null_open_windows

0 comments on commit 963e2a1

Please sign in to comment.