diff --git a/lib/fluent/plugin/storage_local.rb b/lib/fluent/plugin/storage_local.rb index 7ccad620db..d6107efbb1 100644 --- a/lib/fluent/plugin/storage_local.rb +++ b/lib/fluent/plugin/storage_local.rb @@ -87,7 +87,12 @@ 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 = Yajl::Parser.parse(open(@path, 'r:utf-8'){ |io| io.read }) + data = open(@path, 'r:utf-8') { |io| io.read } + if data.empty? + log.warn "detect empty plugin storage file during startup. Ignored: #{@path}" + return + end + data = Yajl::Parser.parse(data) raise Fluent::ConfigError, "Invalid contents (not object) in plugin storage file: '#{@path}'" unless data.is_a?(Hash) rescue => e log.error "failed to read data from plugin storage file", path: @path, error: e