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: bc4b090ecd04
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b607f5258d3a
Choose a head ref

Commits on Sep 15, 2016

  1. Format initial string to specific precision, so rounding works.

    The logic in our double-based sprintf logic attempts to round
    values manually by inspecting a long-form version of the double.
    If we need to round, and the next digit is a five, it will round
    toward zero (truncate) iff that five is the last digit in the long
    unrounded string. This appears to have been an attempt to mimic
    C printf's behavior of rounding "true half" to even in the
    presence of inaccurately-represented IEEE754 decimals.
    
    This commit changes the pre-formatting to actually format with the
    specified precision, allowing NumberFormat's default HALF_EVEN
    logic to to the work for us.
    
    Fixes #4157.
    headius committed Sep 15, 2016
    Copy the full SHA
    6cef061 View commit details

Commits on Sep 30, 2016

  1. Inspect directly into a RubyString and avoid StringBuilder/char[].

    This should reduce the overhead of inspecting by avoiding the
    intermediate StringBuilder/char[] and subsequent conversion to
    byte[]. There are a few extra objects created along the way
    (java.lang.String.getBytes, RubyString for class name, etc) but
    overall memory use should reduce around 3x: a US-ASCII
    string would need 2x byte size in the StringBuilder, and the
    builder is still alive when we create the eventual byte[] for a
    total of 3x max memory use during inspect.
    
    Relates to #4127, but does not constitute a fix for memory issues
    there.
    headius committed Sep 30, 2016
    Copy the full SHA
    a40621d View commit details
  2. Copy the full SHA
    8131146 View commit details

Commits on Oct 10, 2016

  1. Copy the full SHA
    f7263a2 View commit details
  2. Copy the full SHA
    9d880cf View commit details
  3. Copy the full SHA
    d73a809 View commit details
  4. Copy the full SHA
    3f36e15 View commit details
  5. Copy the full SHA
    76120f9 View commit details
  6. Clean up unused imports.

    headius authored and etehtsea committed Oct 10, 2016
    Copy the full SHA
    093d234 View commit details
  7. Copy the full SHA
    9bcfdd8 View commit details
  8. Add UDPSocket.new specs

    etehtsea committed Oct 10, 2016
    Copy the full SHA
    6227536 View commit details
  9. Fixes for UDPSocket.send based on rubysl-socket specs.

    * Handle Addrinfo or packed sockaddr as destination.
    * Try all addresses for a given hostname.
    headius authored and etehtsea committed Oct 10, 2016
    Copy the full SHA
    b56a192 View commit details
  10. Untag related mri tests

    etehtsea committed Oct 10, 2016
    Copy the full SHA
    d659903 View commit details
  11. Last fixes for UDPSocket based on rubysl-socket specs.

    * Handle family argument to initialize better.
    * Try all addresses for connect when no explicit family specified.
    * Raise proper error for wrong family.
    headius authored and etehtsea committed Oct 10, 2016
    Copy the full SHA
    9337fdd View commit details
  12. Copy the full SHA
    2c34eff View commit details
  13. Copy the full SHA
    4207acd View commit details

Commits on Oct 11, 2016

  1. Fix Addrinfo initialization

    Fixed initialization with nil nodename
    `Addrinfo.new(['AF_INET6', 59656, nil, '::1'], 30, 1, 6)`
    etehtsea committed Oct 11, 2016
    Copy the full SHA
    a5bf7de View commit details
  2. Copy the full SHA
    feba193 View commit details
  3. Copy the full SHA
    869c5e5 View commit details
  4. Merge pull request #4216 from etehtsea/socket-udp-improvements

    UDP socket improvements
    headius authored Oct 11, 2016
    Copy the full SHA
    1a6f27a View commit details
  5. Copy the full SHA
    a65df74 View commit details
  6. Copy the full SHA
    e3c44b1 View commit details
  7. Copy the full SHA
    38ee84d View commit details
  8. Properly coerce shutdown argument.

    headius authored and etehtsea committed Oct 11, 2016
    Copy the full SHA
    68e7ba5 View commit details
  9. Copy the full SHA
    7e6e8cc View commit details
  10. Fix up BasicSocket#close_read and close_write.

    Passes specs in rubysl-socket.
    headius authored and etehtsea committed Oct 11, 2016
    Copy the full SHA
    b9d6a49 View commit details
  11. Copy the full SHA
    a4dd94c View commit details
  12. Copy the full SHA
    4d15290 View commit details
  13. Merge pull request #4214 from jruby/jnr-posix-getgroups

    [Truffle] Use the new getgroups POSIX call.
    enebo authored Oct 11, 2016
    Copy the full SHA
    b99152c View commit details

Commits on Oct 12, 2016

  1. Copy the full SHA
    dd22224 View commit details
  2. Copy the full SHA
    def7839 View commit details
  3. Fix UNIXServer#accept_nonblock(exception: false)

    Introduced in cc79119
    etehtsea committed Oct 12, 2016
    Copy the full SHA
    57e672c View commit details
  4. Copy the full SHA
    8cd1cbe View commit details
  5. Fix the incorrect opscode mapping in f2i()

     - f2i() should be mapped to F2I, instead of F2D.
     - The incorrect opscode mapping appears to be a copy-paste editing error.
     - Due to the error, when float-to-integer narrowing numeric conversion should occur,
       float-to-double widening numeric conversion was being done, which can have a
       negative impact on performance or memory usage.
    sangmokh authored Oct 12, 2016
    Copy the full SHA
    7e1c5e5 View commit details
  6. Merge pull request #4220 from etehtsea/eaddrinuse

    Handle EADDRINUSE message in IOException.
    enebo authored Oct 12, 2016
    Copy the full SHA
    2a091bc View commit details
  7. Merge pull request #4221 from etehtsea/unix-socket-improvements

    UNIX sockets improvements
    enebo authored Oct 12, 2016
    Copy the full SHA
    8a8d577 View commit details
  8. Merge pull request #4222 from etehtsea/basicsocket-improvements

    BasicSocket improvements
    enebo authored Oct 12, 2016
    Copy the full SHA
    2c86bfd View commit details
  9. Merge pull request #4224 from himosqui/patch-2

    Fix the incorrect opscode mapping in f2i()
    enebo authored Oct 12, 2016
    Copy the full SHA
    7c55b3b View commit details
  10. Merge pull request #4128 from headius/lighter_inspect

    Inspect directly into a RubyString and avoid StringBuilder/char[].
    enebo authored Oct 12, 2016
    Copy the full SHA
    256042b View commit details
  11. Merge pull request #4159 from headius/sprintf_rounding

    Format initial string to specific precision, so rounding works.
    enebo authored Oct 12, 2016
    Copy the full SHA
    7f9866b View commit details
  12. Update for released jnr-posix

    enebo committed Oct 12, 2016
    Copy the full SHA
    576e401 View commit details

Commits on Oct 13, 2016

  1. 1
    Copy the full SHA
    ee0b9b1 View commit details

Commits on Oct 16, 2016

  1. Copy the full SHA
    d573d28 View commit details
  2. Copy the full SHA
    b607f52 View commit details
Showing with 410 additions and 206 deletions.
  1. +7 −1 core/pom.rb
  2. +10 −1 core/pom.xml
  3. +6 −0 core/src/main/java/org/jruby/Ruby.java
  4. +32 −14 core/src/main/java/org/jruby/RubyBasicObject.java
  5. +1 −1 core/src/main/java/org/jruby/compiler/impl/SkinnyMethodAdapter.java
  6. +33 −38 core/src/main/java/org/jruby/ext/socket/Addrinfo.java
  7. +1 −1 core/src/main/java/org/jruby/ext/socket/Ifaddr.java
  8. +40 −50 core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
  9. +6 −9 core/src/main/java/org/jruby/ext/socket/RubySocket.java
  10. +97 −46 core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
  11. +4 −1 core/src/main/java/org/jruby/ext/socket/RubyUNIXServer.java
  12. +2 −2 core/src/main/java/org/jruby/ext/socket/RubyUNIXSocket.java
  13. +1 −1 core/src/main/java/org/jruby/ext/socket/SocketType.java
  14. +5 −5 core/src/main/java/org/jruby/ext/socket/SocketUtils.java
  15. +20 −6 core/src/main/java/org/jruby/ext/socket/SocketUtilsIPV6.java
  16. +2 −1 core/src/main/java/org/jruby/ir/IRBuilder.java
  17. +5 −4 core/src/main/java/org/jruby/util/Sprintf.java
  18. +10 −0 core/src/main/java/org/jruby/util/io/EncodingUtils.java
  19. +60 −16 core/src/main/java/org/jruby/util/io/Sockaddr.java
  20. +2 −1 maven/jruby-complete/pom.rb
  21. +32 −0 spec/ruby/language/method_spec.rb
  22. +30 −0 spec/ruby/library/socket/udpsocket/new_spec.rb
  23. +2 −0 spec/truffle/tags/library/socket/udpsocket/new_tags.txt
  24. +0 −2 test/mri/excludes/TestSocketAddrinfo.rb
  25. +0 −1 test/mri/excludes/TestSocket_BasicSocket.rb
  26. +0 −3 test/mri/excludes/TestSocket_UNIXSocket.rb
  27. +1 −1 tool/jt.rb
  28. +1 −1 truffle/src/main/java/org/jruby/truffle/platform/posix/JNRTrufflePosix.java
8 changes: 7 additions & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
jar 'com.github.jnr:jnr-enxio:0.13', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.13', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.30', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.31', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.4', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.0'
jar 'com.github.jnr:jffi:${jffi.version}'
@@ -281,12 +281,18 @@

[:all, :release, :main, :osgi, :j2ee, :complete, :dist, :'jruby_complete_jar_extended', :'jruby-jars' ].each do |name|
profile name do
# we shade in all dependencies which use the asm classes and relocate
# the asm package-name. with all jruby artifacts behave the same
# regarding asm: lib/jruby, jruby-core and jruby-complete via maven
plugin :shade do
execute_goals( 'shade',
:id => 'shade the asm classes',
:phase => 'package',
'artifactSet' => {
# IMPORTANT these needs to match exclusions in
# maven/jruby-complete/pom.rb
'includes' => [ 'com.github.jnr:jnr-ffi',
'me.qmx.jitescript:jitescript',
'org.ow2.asm:*' ]
},
'relocations' => [ { 'pattern' => 'org.objectweb',
11 changes: 10 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.30</version>
<version>3.0.31</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -687,6 +687,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -720,6 +721,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -753,6 +755,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -786,6 +789,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -819,6 +823,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -852,6 +857,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -885,6 +891,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -918,6 +925,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
@@ -951,6 +959,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactSet>
<includes>
<include>com.github.jnr:jnr-ffi</include>
<include>me.qmx.jitescript:jitescript</include>
<include>org.ow2.asm:*</include>
</includes>
</artifactSet>
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3778,6 +3778,10 @@ public RaiseException newErrnoEINTRError() {
return newRaiseException(getErrno().getClass("EINTR"), "Interrupted");
}

public RaiseException newErrnoEAFNOSUPPORTError(String message) {
return newRaiseException(getErrno().getClass("EAFNOSUPPORT"), message);
}

public RaiseException newErrnoFromLastPOSIXErrno() {
RubyClass errnoClass = getErrno(getPosix().errno());
if (errnoClass == null) errnoClass = systemCallError;
@@ -4098,6 +4102,8 @@ public RaiseException newIOErrorFromException(final IOException ex) {
return newErrnoENFILEError();
case "Network is unreachable" :
return newErrnoENETUNREACHError();
case "Address already in use" :
return newErrnoEADDRINUSEError();
default :
if ( Platform.IS_WINDOWS ) {
if ( errorMessage.contains("connection was aborted") ) {
46 changes: 32 additions & 14 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
package org.jruby;

import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.ir.interpreter.Interpreter;
import org.jruby.runtime.Constants;
import org.jruby.runtime.JavaSites;
@@ -69,6 +70,7 @@
import org.jruby.runtime.component.VariableEntry;
import org.jruby.runtime.marshal.CoreObjectType;
import org.jruby.util.ArraySupport;
import org.jruby.util.ConvertBytes;
import org.jruby.util.IdUtil;
import org.jruby.util.TypeConverter;
import org.jruby.util.unsafe.UnsafeHolder;
@@ -78,6 +80,9 @@
import static org.jruby.runtime.invokedynamic.MethodNames.OP_CMP;
import static org.jruby.runtime.invokedynamic.MethodNames.EQL;
import static org.jruby.runtime.invokedynamic.MethodNames.INSPECT;
import static org.jruby.util.io.EncodingUtils.encStrBufCat;
import static org.jruby.util.io.EncodingUtils.strBufCat;

import org.jruby.runtime.ivars.VariableTableManager;

/**
@@ -1096,21 +1101,30 @@ public IRubyObject inspect() {
return to_s();
}

private static final byte[] INSPECT_POUND_LT = "#<".getBytes();
private static final byte[] INSPECT_COLON_ZERO_X = ":0x".getBytes();
private static final byte[] INSPECT_SPACE_DOT_DOT_DOT_GT = " ...>".getBytes();
private static final byte[] INSPECT_COMMA = ",".getBytes();
private static final byte[] INSPECT_SPACE = " ".getBytes();
private static final byte[] INSPECT_EQUALS = "=".getBytes();
private static final byte[] INSPECT_GT = ">".getBytes();

public final IRubyObject hashyInspect() {
final Ruby runtime = getRuntime();
String cname = getMetaClass().getRealClass().getName();
StringBuilder part = new StringBuilder(2 + cname.length() + 3 + 8 + 1); // #<Object:0x5a1c0542>
part.append("#<").append(cname).append(":0x");
part.append(Integer.toHexString(inspectHashCode()));
byte[] name = getMetaClass().getRealClass().getName().getBytes(RubyEncoding.UTF8);
RubyString part = RubyString.newStringLight(runtime, 2 + name.length + 3 + 8 + 1); // #<Object:0x5a1c0542>
encStrBufCat(runtime, part, INSPECT_POUND_LT);
encStrBufCat(runtime, part, name, UTF8Encoding.INSTANCE);
encStrBufCat(runtime, part, INSPECT_COLON_ZERO_X);
encStrBufCat(runtime, part, ConvertBytes.longToHexBytes(inspectHashCode()));

if (runtime.isInspecting(this)) {
/* 6:tags 16:addr 1:eos */
part.append(" ...>");
return RubyString.newString(runtime, part);
encStrBufCat(runtime, part, INSPECT_SPACE_DOT_DOT_DOT_GT);
return part;
}
try {
runtime.registerInspecting(this);
return RubyString.newString(runtime, inspectObj(runtime, part));
return inspectObj(runtime, part);
} finally {
runtime.unregisterInspecting(this);
}
@@ -1150,21 +1164,25 @@ protected int inspectHashCode() {
* The internal helper method that takes care of the part of the
* inspection that inspects instance variables.
*/
private StringBuilder inspectObj(final Ruby runtime, StringBuilder part) {
private RubyString inspectObj(final Ruby runtime, RubyString part) {
final ThreadContext context = runtime.getCurrentContext();
String sep = "";

boolean first = true;
for (Map.Entry<String, VariableAccessor> entry : metaClass.getVariableTableManager().getVariableAccessorsForRead().entrySet()) {
Object value = entry.getValue().get(this);
if (!(value instanceof IRubyObject) || !IdUtil.isInstanceVariable(entry.getKey())) continue;

IRubyObject obj = (IRubyObject) value;

part.append(sep).append(' ').append(entry.getKey()).append('=');
part.append(sites(context).inspect.call(context, obj, obj));
sep = ",";
if (!first) encStrBufCat(runtime, part, INSPECT_COMMA);
encStrBufCat(runtime, part, INSPECT_SPACE);
encStrBufCat(runtime, part, entry.getKey().getBytes());
encStrBufCat(runtime, part, INSPECT_EQUALS);
encStrBufCat(runtime, part, sites(context).inspect.call(context, obj, obj).convertToString().getByteList());

first = false;
}
part.append('>');
encStrBufCat(runtime, part, INSPECT_GT);
return part;
}

Original file line number Diff line number Diff line change
@@ -799,7 +799,7 @@ public void f2d() {
}

public void f2i() {
getMethodVisitor().visitInsn(F2D);
getMethodVisitor().visitInsn(F2I);
}

public void f2l() {
71 changes: 33 additions & 38 deletions core/src/main/java/org/jruby/ext/socket/Addrinfo.java
Original file line number Diff line number Diff line change
@@ -16,13 +16,10 @@
import org.jruby.RubyObject;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.Visibility;
import org.jruby.util.ByteList;

import java.io.ByteArrayOutputStream;
@@ -36,9 +33,9 @@
import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.UnknownHostException;
import java.net.SocketException;

import java.util.regex.Pattern;
import org.jruby.exceptions.RaiseException;

import org.jruby.util.TypeConverter;
import org.jruby.util.io.Sockaddr;

@@ -174,6 +171,7 @@ private void initializeCommon(ThreadContext context, IRubyObject sockaddr, IRuby

try {
IRubyObject _sockaddrAry = TypeConverter.checkArrayType(sockaddr);

if (!_sockaddrAry.isNil()) {
RubyArray sockaddAry = (RubyArray)_sockaddrAry;

@@ -199,17 +197,13 @@ private void initializeCommon(ThreadContext context, IRubyObject sockaddr, IRuby
IRubyObject nodename = sockaddAry.eltOk(2);
IRubyObject numericnode = sockaddAry.eltOk(3);

if (!nodename.isNil()) {
nodename = nodename.convertToString();
}
numericnode = numericnode.convertToString();

InetAddress inetAddress = null;
int _port = service.convertToInteger().getIntValue();
try {
socketAddress = new InetSocketAddress(SocketUtils.getRubyInetAddress(nodename.convertToString().getByteList()), _port);
} catch (UnknownHostException uhe) {
socketAddress = new InetSocketAddress(SocketUtils.getRubyInetAddress(numericnode.convertToString().getByteList()), _port);
}

if (!nodename.isNil()) inetAddress = getRubyInetAddress(nodename);
if (inetAddress == null) inetAddress = getRubyInetAddress(numericnode);

this.socketAddress = new InetSocketAddress(inetAddress, _port);

// fall through below to finish setting up
} else {
@@ -222,28 +216,27 @@ private void initializeCommon(ThreadContext context, IRubyObject sockaddr, IRuby

InetAddress inetAddress = null;

try {
inetAddress = SocketUtils.getRubyInetAddress(sockaddrString.getByteList());

int _port;
if (port != null) {
_port = SocketUtils.portToInt(port);
} else {
_port = 0;
}

this.socketAddress = new InetSocketAddress(inetAddress, _port);

if (getInetAddress() instanceof Inet4Address) {
this.pfamily = PF_INET;
} else {
this.pfamily = PF_INET6;
}
} catch (UnknownHostException uhe) {
inetAddress = getRubyInetAddress(sockaddr);
if (inetAddress == null) {
// try unpacking
// FIXME: inefficient to allow exception before trying unpack
this.socketAddress = Sockaddr.sockaddrFromBytes(runtime, sockaddr.convertToString().getBytes());
}

int _port;
if (port != null) {
_port = SocketUtils.portToInt(port);
} else {
_port = 0;
}

this.socketAddress = new InetSocketAddress(inetAddress, _port);

if (getInetAddress() instanceof Inet4Address) {
this.pfamily = PF_INET;
} else {
this.pfamily = PF_INET6;
}
}

this.socketType = SocketType.SOCKET;
@@ -294,7 +287,6 @@ public IRubyObject inspect_sockaddr(ThreadContext context) {

int port = getInetSocketAddress().getPort();

// getHostAddress() returns ip in the full form, but MRI uses short;
if (getInetAddress() instanceof Inet6Address) {
String host = ipv6_ip();
String hostPort = port == 0 ? host : "[" + host + "]:" + port;
@@ -669,11 +661,15 @@ private String ipv6_ip() {
InetAddress in = getInetAddress();

if (in.isLoopbackAddress()) return "::1";
return ipv6Compact(in.getHostAddress());
return SocketUtilsIPV6.getIPV6Address(in.getHostAddress());
}

private static String ipv6Compact(String fullHost) {
return IPV6_COMPACT.matcher(fullHost).replaceAll("::$2");
private InetAddress getRubyInetAddress(IRubyObject node) {
try {
return SocketUtils.getRubyInetAddresses(node.convertToString().getByteList())[0];
} catch (UnknownHostException uhe) {
return null;
}
}

@JRubyMethod(optional = 1)
@@ -788,5 +784,4 @@ AddressFamily getAddressFamily() {
private NetworkInterface networkInterface;
private boolean isBroadcast;
private Protocol protocol = Protocol.getProtocolByNumber(0);
private static final Pattern IPV6_COMPACT = Pattern.compile("((?::0\\b){2,}):?(?!\\S*\\b\\1:0\\b)(\\S*)");
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/socket/Ifaddr.java
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ private void setNetmask(InterfaceAddress it) throws Exception {
SubnetUtils utils = new SubnetUtils(subnet);
netmask = utils.getInfo().getNetmask();
} else if ( (it.getNetworkPrefixLength() != 0 ) && ( address instanceof Inet6Address) ) {
netmask = new SocketUtilsIPV6().getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength());
netmask = SocketUtilsIPV6.getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength());
}
}

Loading