Skip to content

Commit eaa1047

Browse files
committed
Remove JRuby-specifiy SocketPoller#listening?
The related issue in JRuby has been fixed and is available since 9.2.8.0
1 parent c39edad commit eaa1047

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

rb/lib/selenium/webdriver/common/socket_poller.rb

+19-30
Original file line numberDiff line numberDiff line change
@@ -65,37 +65,26 @@ def closed?
6565
arr << Errno::EALREADY if Platform.wsl?
6666
}.freeze
6767

68-
if Platform.jruby?
69-
# we use a plain TCPSocket here since JRuby has issues closing socket
70-
# see https://github.com/jruby/jruby/issues/5709
71-
def listening?
72-
TCPSocket.new(@host, @port).close
73-
true
74-
rescue *NOT_CONNECTED_ERRORS
75-
false
76-
end
77-
else
78-
def listening?
79-
addr = Socket.getaddrinfo(@host, @port, Socket::AF_INET, Socket::SOCK_STREAM)
80-
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
81-
sockaddr = Socket.pack_sockaddr_in(@port, addr[0][3])
82-
83-
begin
84-
sock.connect_nonblock sockaddr
85-
rescue Errno::EINPROGRESS
86-
retry if socket_writable?(sock) && conn_completed?(sock)
87-
raise Errno::ECONNREFUSED
88-
rescue *CONNECTED_ERRORS
89-
# yay!
90-
end
91-
92-
sock.close
93-
true
94-
rescue *NOT_CONNECTED_ERRORS
95-
sock&.close
96-
WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
97-
false
68+
def listening?
69+
addr = Socket.getaddrinfo(@host, @port, Socket::AF_INET, Socket::SOCK_STREAM)
70+
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
71+
sockaddr = Socket.pack_sockaddr_in(@port, addr[0][3])
72+
73+
begin
74+
sock.connect_nonblock sockaddr
75+
rescue Errno::EINPROGRESS
76+
retry if socket_writable?(sock) && conn_completed?(sock)
77+
raise Errno::ECONNREFUSED
78+
rescue *CONNECTED_ERRORS
79+
# yay!
9880
end
81+
82+
sock.close
83+
true
84+
rescue *NOT_CONNECTED_ERRORS
85+
sock&.close
86+
WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
87+
false
9988
end
10089

10190
def socket_writable?(sock)

0 commit comments

Comments
 (0)