From 17fd9d268f778b61c76c84e52742e7756e317d85 Mon Sep 17 00:00:00 2001 From: Yury Lebedev Date: Fri, 2 Feb 2024 18:48:11 +0100 Subject: [PATCH] Fix conflict with resolv-replace gem Closes #987 In version 3.2.7 socket_timeout option was introduced for TCPSocket. This works unless `resolv-replace` gem is loaded (which was added to ruby standard library since version 3.0.0). This commit adds another check besides the ruby version check to avoid breaking dalli for applications that have `resolv-replace` gem required. --- lib/dalli/socket.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dalli/socket.rb b/lib/dalli/socket.rb index 48f3c3f2..cd5d081b 100644 --- a/lib/dalli/socket.rb +++ b/lib/dalli/socket.rb @@ -88,7 +88,8 @@ class TCP < TCPSocket # options - supports enhanced logging in the case of a timeout attr_accessor :options - if RUBY_VERSION >= '3.0' + if RUBY_VERSION >= '3.0' && + !::TCPSocket.private_instance_methods.include?(:original_resolv_initialize) def self.open(host, port, options = {}) sock = new(host, port, connect_timeout: options[:socket_timeout]) sock.options = { host: host, port: port }.merge(options)