Skip to content

Commit 41a6fb7

Browse files
committed
UnixSocketChannel is SocketChannel so flip type checks
1 parent 9d8be5d commit 41a6fb7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

core/src/main/java/org/jruby/ext/socket/RubySocket.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,14 @@ private boolean tryConnect(ThreadContext context, Channel channel, SocketAddress
519519

520520
while (true) {
521521
boolean result = true;
522-
if (channel instanceof SocketChannel) {
522+
if (channel instanceof UnixSocketChannel unix) {
523+
if (unix.isConnectionPending()) {
524+
// connection initiated but not finished
525+
result = unix.finishConnect();
526+
} else {
527+
result = unix.connect(addr);
528+
}
529+
} else if (channel instanceof SocketChannel) {
523530
SocketChannel socket = (SocketChannel) channel;
524531

525532
if (socket.isConnected()) {
@@ -530,9 +537,6 @@ private boolean tryConnect(ThreadContext context, Channel channel, SocketAddress
530537
} else {
531538
result = socket.connect(addr);
532539
}
533-
} else if (channel instanceof UnixSocketChannel) {
534-
result = ((UnixSocketChannel) channel).connect((UnixSocketAddress) addr);
535-
536540
} else if (channel instanceof DatagramChannel datagram) {
537541
datagram.connect(addr);
538542
} else {

0 commit comments

Comments
 (0)