Skip to content

Commit db069ce

Browse files
Fix JRuby 10.1 compatibility in supports_connect_timeout?
JRuby 10.1.0.0 (Ruby 4.0 compat) does not support instance_method on its Java-backed TCPSocket, causing NoMethodError on every connection attempt. Guard the introspection with RUBY_ENGINE == 'ruby' so JRuby falls back to Timeout.timeout, consistent with the existing MRI-specific skip guard in the test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5139d8b commit db069ce

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/dalli/socket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def self.open(host, port, options = {})
112112
def self.supports_connect_timeout?
113113
return @supports_connect_timeout if defined?(@supports_connect_timeout)
114114

115-
@supports_connect_timeout = RUBY_VERSION >= '3.0' &&
115+
@supports_connect_timeout = RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '3.0' &&
116116
::TCPSocket.instance_method(:initialize).parameters == TCPSOCKET_NATIVE_PARAMETERS
117117
end
118118
# rubocop:enable ThreadSafety/ClassInstanceVariable

test/test_socket.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
it 'detects when TCPSocket#initialize parameters have changed' do
4242
skip 'Ruby 3.0+ required' if RUBY_VERSION < '3.0'
43+
skip 'MRI-specific test' if RUBY_ENGINE != 'ruby'
4344

4445
# Get the expected native parameters
4546
native_params = [[:rest]]

0 commit comments

Comments
 (0)