Skip to content

Commit

Permalink
Showing 5 changed files with 41 additions and 10 deletions.
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/ext/ffi/Platform.java
Original file line number Diff line number Diff line change
@@ -239,8 +239,13 @@ protected Platform(OS_TYPE os) {
// remove additional version identifiers, e.g. -ea
versionString = versionString.split("-|\\+")[0];
String[] v = versionString.split("\\.");
// starting from JDK 9, there is no leading "1." in java.version
version = Integer.valueOf(v.length > 1 ? v[1] : v[0]);
if (v[0].equals("1")) {
// Pre Java 9, 1.x style
version = Integer.valueOf(v[1]);
} else {
// Java 9+, x.y.z style
version = Integer.valueOf(v[0]);
}
}
} catch (Exception ex) {
version = 0;
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
@@ -212,6 +212,8 @@ public static Errno errnoFromException(Throwable t) {
case "Message too large": // Alpine Linux
case "Message too long":
return Errno.EMSGSIZE;
case "Is a directory":
return Errno.EISDIR;
}
}
return null;
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
@@ -1407,6 +1407,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 {
19 changes: 11 additions & 8 deletions test/jruby/test_addrinfo.rb
Original file line number Diff line number Diff line change
@@ -110,16 +110,19 @@ def test_ipv6?
end
end

def test_ipv6_loopback?
loopbacks = getaddrs.select do |addr|
if addr.afamily == Socket::AF_INET6
addr.ipv6_loopback?
else
assert_equal(false, addr.ipv6_loopback?)
nil
# Travis CI's 'trusty' environment no longer has IP6 (travis-ci/travis-ci#4964)
unless ENV['TRAVIS']
def test_ipv6_loopback?
loopbacks = getaddrs.select do |addr|
if addr.afamily == Socket::AF_INET6
addr.ipv6_loopback?
else
assert_equal(false, addr.ipv6_loopback?)
nil
end
end
assert_equal(1, loopbacks.count) # only one ipv6 loopback
end
assert_equal(1, loopbacks.count) # only one ipv6 loopback
end

def test_pfamily
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 0b72b03

Please sign in to comment.