Skip to content

Commit

Permalink
Call dup not to overwrite original value
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <[email protected]>
  • Loading branch information
ganmacs committed Jan 27, 2020
1 parent 38f80c5 commit 6d53664
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/fluent/config/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def to_h
@params
end

def dup
Section.new(@params.dup, @corresponding_config_element.dup)
end

def +(other)
Section.new(self.to_h.merge(other.to_h))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/http_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def stop
private

def _http_server_overwrite_config(config, opts)
conf = config
conf = config.dup
Fluent::PluginHelper::Server::SERVER_TRANSPORT_PARAMS.map(&:to_s).each do |param|
if opts.key?(param)
conf[param] = opts[param]
Expand Down
2 changes: 0 additions & 2 deletions test/config/test_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class TestSection < ::Test::Unit::TestCase
assert_equal("email", s1.send)
assert_equal("normal", s1.klass)
assert_equal(5, s1.keys)

assert_raise(NoMethodError) { s1.dup }
end

test 'creates object which contains specified hash object itself, including fields with at prefix' do
Expand Down

0 comments on commit 6d53664

Please sign in to comment.