From 883b86112bf73fa88c153a74cced501c7f799db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sat, 25 Apr 2020 08:59:46 +0200 Subject: [PATCH] Fix `UserFileDefaultOptions#fetch` implementation (#2233) The usage of `||` fetch is incorrect, as presence of `false` is the correct value. This change uses `default` value, only if the value is nowhere else defined. --- History.md | 1 + lib/puma/configuration.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index d7f8562537..ce96413323 100644 --- a/History.md +++ b/History.md @@ -38,6 +38,7 @@ * Fixed a few minor concurrency bugs in ThreadPool that may have affected non-GVL Rubies (#2220) * Fix `out_of_band` hook never executed if the number of worker threads is > 1 (#2177) * Fix ThreadPool#shutdown timeout accuracy (#2221) + * Fix `UserFileDefaultOptions#fetch` to properly use `default` (#2233) * Refactor * Remove unused loader argument from Plugin initializer (#2095) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index 29d953c9fe..f244c3078d 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -54,9 +54,7 @@ def initialize(user_options, default_options) attr_reader :user_options, :file_options, :default_options def [](key) - return user_options[key] if user_options.key?(key) - return file_options[key] if file_options.key?(key) - return default_options[key] if default_options.key?(key) + fetch(key) end def []=(key, value) @@ -64,7 +62,11 @@ def []=(key, value) end def fetch(key, default_value = nil) - self[key] || default_value + return user_options[key] if user_options.key?(key) + return file_options[key] if file_options.key?(key) + return default_options[key] if default_options.key?(key) + + default_value end def all_of(key)