Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puma/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def shift
end

def [](key)
@set.each do |o|
@set.reverse_each do |o|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flatten method uses inconsistent priority after [] change

Medium Severity

The [] method now uses reverse_each to give later levels higher priority (last wins), but the flatten method still uses forward @set.each with ||=, which gives earlier levels higher priority (first wins). This causes options[:key] and options.flatten[:key] to return different values when the same key exists in multiple levels, breaking consistency when flatten! is called.

Fix in Cursor Fix in Web

if o.key? key
return o[key]
end
Expand Down
11 changes: 11 additions & 0 deletions test/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def test_allow_users_to_override_default_options
assert_equal 'bin/rails server', conf.options[:restart_cmd]
end

def test_overwrite_options
conf = Puma::Configuration.new do |c|
c.workers 3
end
conf.load

assert_equal conf.options[:workers], 3
conf.options[:workers] += 1
assert_equal conf.options[:workers], 4
end

private

def with_env(env = {})
Expand Down