diff --git a/lib/faraday/middleware.rb b/lib/faraday/middleware.rb index 9532b755..52d8287b 100644 --- a/lib/faraday/middleware.rb +++ b/lib/faraday/middleware.rb @@ -10,6 +10,7 @@ class Middleware attr_reader :app, :options DEFAULT_OPTIONS = {}.freeze + LOCK = Mutex.new def initialize(app = nil, options = {}) @app = app @@ -27,7 +28,7 @@ class << self # def default_options=(options = {}) validate_default_options(options) - lock.synchronize do + LOCK.synchronize do @default_options = default_options.merge(options) end end @@ -41,10 +42,6 @@ def default_options private - def lock - @lock ||= Monitor.new - end - def validate_default_options(options) invalid_keys = options.keys.reject { |opt| self::DEFAULT_OPTIONS.key?(opt) } return unless invalid_keys.any?