Skip to content

Commit

Permalink
Fix conflict with resolv-replace gem
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
y9v committed Feb 2, 2024
1 parent c409a07 commit 17fd9d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/dalli/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 17fd9d2

Please sign in to comment.