From 151e6314a371add407f602d50cb8be777109afd1 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Thu, 6 Jun 2024 13:47:03 +0900 Subject: [PATCH] parser_json: fix wrong LoadError warning If Oj is not installed, LoadError with the empty message is raised. So, the current condition `/\boj\z/.match?(ex.message)` does not work and the following meaningless warning is displayed. {datetime} [warn]: #x {id} LoadError After this fix, the log message will be: {datetime} [info]: #x {id} Oj is not installed, and failing back to Yajl for json parser Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/parser_json.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fluent/plugin/parser_json.rb b/lib/fluent/plugin/parser_json.rb index 52dd6f5e8f..1a2362990e 100644 --- a/lib/fluent/plugin/parser_json.rb +++ b/lib/fluent/plugin/parser_json.rb @@ -58,14 +58,14 @@ def configure_json_parser(name) raise "BUG: unknown json parser specified: #{name}" end rescue LoadError => ex - name = :yajl if log - if /\boj\z/.match?(ex.message) + if name == :oj log.info "Oj is not installed, and failing back to Yajl for json parser" else log.warn ex.message end end + name = :yajl retry end