diff --git a/lib/fluent/config/types.rb b/lib/fluent/config/types.rb index 75dfde385d..66ef37ad39 100644 --- a/lib/fluent/config/types.rb +++ b/lib/fluent/config/types.rb @@ -186,7 +186,7 @@ def self.hash_value(val, opts = {}, name = nil) return nil if val.nil? param = if val.is_a?(String) - val.start_with?('{') ? JSON.load(val) : Hash[val.strip.split(/\s*,\s*/).map{|v| v.split(':', 2)}] + val.start_with?('{') ? JSON.parse(val) : Hash[val.strip.split(/\s*,\s*/).map{|v| v.split(':', 2)}] else val end @@ -213,7 +213,7 @@ def self.array_value(val, opts = {}, name = nil) return nil if val.nil? param = if val.is_a?(String) - val.start_with?('[') ? JSON.load(val) : val.strip.split(/\s*,\s*/) + val.start_with?('[') ? JSON.parse(val) : val.strip.split(/\s*,\s*/) else val end diff --git a/lib/fluent/plugin/storage_local.rb b/lib/fluent/plugin/storage_local.rb index 9fa88dfcb7..1ae0c6cd54 100644 --- a/lib/fluent/plugin/storage_local.rb +++ b/lib/fluent/plugin/storage_local.rb @@ -87,7 +87,7 @@ def configure(conf) if File.exist?(@path) raise Fluent::ConfigError, "Plugin storage path '#{@path}' is not readable/writable" unless File.readable?(@path) && File.writable?(@path) begin - data = open(@path, 'r:utf-8') { |io| io.read } + data = File.open(@path, 'r:utf-8') { |io| io.read } if data.empty? log.warn "detect empty plugin storage file during startup. Ignored: #{@path}" return @@ -115,7 +115,7 @@ def load return if @on_memory return unless File.exist?(@path) begin - json_string = open(@path, 'r:utf-8'){ |io| io.read } + json_string = File.open(@path, 'r:utf-8'){ |io| io.read } json = Yajl::Parser.parse(json_string) unless json.is_a?(Hash) log.error "broken content for plugin storage (Hash required: ignored)", type: json.class @@ -133,7 +133,7 @@ def save tmp_path = @path + '.tmp' begin json_string = Yajl::Encoder.encode(@store, pretty: @pretty_print) - open(tmp_path, 'w:utf-8', @mode) { |io| io.write json_string; io.fsync } + File.open(tmp_path, 'w:utf-8', @mode) { |io| io.write json_string; io.fsync } File.rename(tmp_path, @path) rescue => e log.error "failed to save data for plugin storage to file", path: @path, tmp: tmp_path, error: e