From 0a65e32d880b724334295cdb454733d1b78a85bb Mon Sep 17 00:00:00 2001 From: Satoshi Moris Tagomori Date: Tue, 1 Mar 2022 13:19:16 +0900 Subject: [PATCH] declare null_value_pattern as regexp because it is a regexp Signed-off-by: Satoshi Moris Tagomori --- lib/fluent/plugin/parser.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/fluent/plugin/parser.rb b/lib/fluent/plugin/parser.rb index 9a6d20a849..0854129f0e 100644 --- a/lib/fluent/plugin/parser.rb +++ b/lib/fluent/plugin/parser.rb @@ -89,7 +89,7 @@ class ParserError < StandardError; end # : format[, timezone] config_param :time_key, :string, default: nil - config_param :null_value_pattern, :string, default: nil + config_param :null_value_pattern, :regexp, default: nil config_param :null_empty_string, :bool, default: false config_param :estimate_current_event, :bool, default: true config_param :keep_time_key, :bool, default: false @@ -115,9 +115,8 @@ def configure(conf) super @time_parser = time_parser_create - @null_value_regexp = @null_value_pattern && Regexp.new(@null_value_pattern) @type_converters = build_type_converters(@types) - @execute_convert_values = @type_converters || @null_value_regexp || @null_empty_string + @execute_convert_values = @type_converters || @null_value_pattern || @null_empty_string @timeout_checker = if @timeout class << self alias_method :parse_orig, :parse @@ -220,7 +219,7 @@ def convert_values(time, record) return time, record end - def string_like_null(value, null_empty_string = @null_empty_string, null_value_regexp = @null_value_regexp) + def string_like_null(value, null_empty_string = @null_empty_string, null_value_regexp = @null_value_pattern) null_empty_string && value.empty? || null_value_regexp && string_safe_encoding(value){|s| null_value_regexp.match(s) } end