From 05b17c071117456ad0709f089d7cf18d6ae39e48 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Tue, 25 Sep 2018 16:59:57 +0900 Subject: [PATCH] Handle LoadError properly Sometimes LoadError is raised while loading oj gem, even if oj gem is installed. Therefore we want to see the correct message of LoadError. For example, Alpine Linux provides the package ruby which does not include bigdecimal and provides ruby-bigdecimal. Signed-off-by: Kenji Okimoto --- lib/fluent/plugin/parser_json.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/fluent/plugin/parser_json.rb b/lib/fluent/plugin/parser_json.rb index 19160ce624..50a80a31c9 100644 --- a/lib/fluent/plugin/parser_json.rb +++ b/lib/fluent/plugin/parser_json.rb @@ -52,9 +52,15 @@ def configure_json_parser(name) else raise "BUG: unknown json parser specified: #{name}" end - rescue LoadError + rescue LoadError => ex name = :yajl - log.info "Oj is not installed, and failing back to Yajl for json parser" if log + if log + if /\boj\z/ =~ ex.message + log.info "Oj is not installed, and failing back to Yajl for json parser" + else + log.warn ex.message + end + end retry end