Skip to content

Commit 1909ca5

Browse files
committed
Ugly workaround for what seems to be a bug in JRuby
On JRuby (9.1.15.0), if IPv6 is globally disabled on the system, we get an EADDRINUSE with the message "Protocol family unavailable". MRI on the other hand gives us a "Errno::EADDRNOTAVAIL" error we already properly handle.
1 parent 1b8bcc7 commit 1909ca5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/internals_test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@ def af_family_supported(af)
334334
begin
335335
sa = Socket.pack_sockaddr_in(1024 + Random.rand(63076), hosts[af])
336336
s.bind(sa)
337-
rescue Errno::EADDRINUSE
337+
rescue Errno::EADDRINUSE => e
338+
# On JRuby (9.1.15.0), if IPv6 is globally disabled on the system,
339+
# we get an EADDRINUSE with belows message.
340+
if e.message =~ /Protocol family unavailable/
341+
return
342+
end
343+
338344
tries -= 1
339345
retry if tries > 0
340346

0 commit comments

Comments
 (0)