Skip to content

Commit

Permalink
Merge pull request #3650 from fluent/declare-null-value-pattern-as-re…
Browse files Browse the repository at this point in the history
…gexp

Declare null_value_pattern as regexp
  • Loading branch information
ashie authored Mar 1, 2022
2 parents a6d8ef1 + 0a65e32 commit 521242c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/fluent/plugin/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 521242c

Please sign in to comment.