Buggy code:
public class RubyTCPSocket extends RubyIPSocket { static void createTCPSocket ( Ruby runtime ) { } private static ObjectAllocator TCPSOCKET_ALLOCATOR = new ObjectAllocator ( ) { public IRubyObject allocate ( Ruby runtime , RubyClass klass ) { } } ; public RubyTCPSocket ( Ruby runtime , RubyClass type ) { } @ JRubyMethod ( required = 2 , optional = 2 , visibility = Visibility . PRIVATE ) public IRubyObject initialize ( ThreadContext context , IRubyObject [ ] args ) { Ruby runtime = context . runtime ; IRubyObject _host = args [ 0 ] ; IRubyObject _port = args [ 1 ] ; String remoteHost = ( _host . isNil ( ) ) ? "localhost" : _host . convertToString ( ) . toString ( ) ; int remotePort = SocketUtils . getPortFrom ( context , _port ) ; String localHost = ( ( ( args . length ) >= 3 ) && ( ! ( args [ 2 ] . isNil ( ) ) ) ) ? args [ 2 ] . convertToString ( ) . toString ( ) : null ; int localPort = ( ( ( args . length ) == 4 ) && ( ! ( args [ 3 ] . isNil ( ) ) ) ) ? SocketUtils . getPortFrom ( context , args [ 3 ] ) : 0 ; boolean success = false ; SocketChannel channel = null ; try { channel = SocketChannel . open ( ) ; Socket socket = channel . socket ( ) ; if ( localHost != null ) { socket . setReuseAddress ( true ) ; socket . bind ( new InetSocketAddress ( InetAddress . getByName ( localHost ) , localPort ) ) ; } try { channel . configureBlocking ( false ) ; channel . connect ( new InetSocketAddress ( InetAddress . getByName ( remoteHost ) , remotePort ) ) ; context . getThread ( ) . select ( channel , this , SelectionKey . OP_CONNECT ) ; channel . finishConnect ( ) ; channel . configureBlocking ( true ) ; initSocket ( newChannelFD ( runtime , channel ) ) ; success = true ; } catch ( BindException e ) { throw runtime . newErrnoEADDRFromBindException ( e , ( ( ( "<seq2seq4repair_space>to:<seq2seq4repair_space>" + remoteHost ) + ":" ) + ( String . valueOf ( remotePort ) ) ) ) ; } catch ( NoRouteToHostException nrthe ) { throw runtime . newErrnoEHOSTUNREACHError ( "SocketChannel.connect" ) ; } catch ( ConnectException e ) { throw runtime . newErrnoECONNREFUSEDError ( ) ; } catch ( UnknownHostException e ) { throw SocketUtils . sockerr ( runtime , "initialize:<seq2seq4repair_space>name<seq2seq4repair_space>or<seq2seq4repair_space>service<seq2seq4repair_space>not<seq2seq4repair_space>known" ) ; } } catch ( ClosedChannelException cce ) { throw runtime . newErrnoECONNREFUSEDError ( ) ; } catch ( BindException e ) { throw runtime . newErrnoEADDRFromBindException ( e , ( ( ( "<seq2seq4repair_space>on:<seq2seq4repair_space>" + localHost ) + ":" ) + ( String . valueOf ( localPort ) ) ) ) ; } catch ( IOException e ) { <START_BUG> throw SocketUtils . sockerr ( runtime , e . getLocalizedMessage ( ) ) ; <END_BUG> } catch ( IllegalArgumentException iae ) { throw SocketUtils . sockerr ( runtime , iae . getMessage ( ) ) ; } finally { if ( ( ! success ) && ( channel != null ) ) { try { channel . close ( ) ; } catch ( IOException ioe ) { } } } return context . nil ; } @ JRubyMethod ( meta = true ) public static IRubyObject gethostbyname ( ThreadContext context , IRubyObject recv , IRubyObject hostname ) { } @ Deprecated public static IRubyObject open ( IRubyObject recv , IRubyObject [ ] args , Block block ) { } @ Deprecated public static IRubyObject gethostbyname ( IRubyObject recv , IRubyObject hostname ) { } }

Fix:
throw runtime . newIOErrorFromException ( e ) ;