From 6d53664d34113381f1c3048c2569ff9e405b456b Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 24 Jan 2020 11:43:06 +0900 Subject: [PATCH] Call dup not to overwrite original value Signed-off-by: Yuta Iwama --- lib/fluent/config/section.rb | 4 ++++ lib/fluent/plugin_helper/http_server.rb | 2 +- test/config/test_section.rb | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/fluent/config/section.rb b/lib/fluent/config/section.rb index 0c00a199e4..6b16da691c 100644 --- a/lib/fluent/config/section.rb +++ b/lib/fluent/config/section.rb @@ -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 diff --git a/lib/fluent/plugin_helper/http_server.rb b/lib/fluent/plugin_helper/http_server.rb index 96de327774..9a7892cbbb 100644 --- a/lib/fluent/plugin_helper/http_server.rb +++ b/lib/fluent/plugin_helper/http_server.rb @@ -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] diff --git a/test/config/test_section.rb b/test/config/test_section.rb index 3a2bf5d6be..8d2d0f366d 100644 --- a/test/config/test_section.rb +++ b/test/config/test_section.rb @@ -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