Skip to content

Commit

Permalink
Use Object.__send__ to avoid conflicting method name
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
  • Loading branch information
ganmacs committed Sep 11, 2019
1 parent 92f56a4 commit 880a4a3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/counter/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def on_message(data)
end

result = safe_run do
send(data['method'], data['params'], data['scope'], data['options'])
__send__(data['method'], data['params'], data['scope'], data['options'])
end
result.merge('id' => data['id'])
rescue => e
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/multi_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def call_lifecycle_method(method_name, checker_name)
@outputs.each do |o|
begin
log.debug "calling #{method_name} on output plugin dynamically created", type: Fluent::Plugin.lookup_type_from_class(o.class), plugin_id: o.plugin_id
o.send(method_name) unless o.send(checker_name)
o.__send__(method_name) unless o.__send__(checker_name)
rescue Exception => e
log.warn "unexpected error while calling #{method_name} on output plugin dynamically created", plugin: o.class, plugin_id: o.plugin_id, error: e
log.warn_backtrace
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def start
def formatter_operate(method_name, &block)
@_formatters.each_pair do |usage, formatter|
begin
formatter.send(method_name)
formatter.__send__(method_name)
block.call(formatter) if block_given?
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, formatter: formatter, error: e
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def start
def parser_operate(method_name, &block)
@_parsers.each_pair do |usage, parser|
begin
parser.send(method_name)
parser.__send__(method_name)
block.call(parser) if block_given?
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, parser: parser, error: e
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def storage_operate(method_name, &block)
@_storages.each_pair do |usage, s|
begin
block.call(s) if block_given?
s.storage.send(method_name)
s.storage.__send__(method_name)
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, storage: s.storage, error: e
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/root_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def shutdown # Fluentd's shutdown sequence is stop, before_shutdown, shutdown, a
lifecycle do |instance, kind|
begin
log.debug "calling #{method} on #{kind} plugin", type: Plugin.lookup_type_from_class(instance.class), plugin_id: instance.plugin_id
instance.send(method) unless instance.send(checker)
instance.__send__(method) unless instance.__send__(checker)
rescue Exception => e
log.warn "unexpected error while calling #{method} on #{kind} plugin", plugin: instance.class, plugin_id: instance.plugin_id, error: e
log.warn_backtrace
Expand Down Expand Up @@ -270,17 +270,17 @@ def shutdown # Fluentd's shutdown sequence is stop, before_shutdown, shutdown, a
operation = "preparing shutdown" # for logging
log.debug "#{operation} #{kind} plugin", type: Plugin.lookup_type_from_class(instance.class), plugin_id: instance.plugin_id
begin
instance.send(:before_shutdown) unless instance.send(:before_shutdown?)
instance.__send__(:before_shutdown) unless instance.__send__(:before_shutdown?)
rescue Exception => e
log.warn "unexpected error while #{operation} on #{kind} plugin", plugin: instance.class, plugin_id: instance.plugin_id, error: e
log.warn_backtrace
end
operation = "shutting down"
log.info "#{operation} #{kind} plugin", type: Plugin.lookup_type_from_class(instance.class), plugin_id: instance.plugin_id
instance.send(:shutdown) unless instance.send(:shutdown?)
instance.__send__(:shutdown) unless instance.__send__(:shutdown?)
else
log.debug "#{operation} #{kind} plugin", type: Plugin.lookup_type_from_class(instance.class), plugin_id: instance.plugin_id
instance.send(method) unless instance.send(checker)
instance.__send__(method) unless instance.__send__(checker)
end
rescue Exception => e
log.warn "unexpected error while #{operation} on #{kind} plugin", plugin: instance.class, plugin_id: instance.plugin_id, error: e
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def attach(supervisor)
supervisor_value = instance_variable_get("@#{param}")
next if supervisor_value.nil? # it's not configured by command line options

system.send("#{param}=", supervisor_value)
system.__send__("#{param}=", supervisor_value)
end
end
}
Expand Down Expand Up @@ -179,7 +179,7 @@ def system_config_override(opts={})
@_system_config = (defined?($_system_config) && $_system_config ? $_system_config : Fluent::Engine.system_config).dup
end
opts.each_pair do |key, value|
@_system_config.send(:"#{key.to_s}=", value)
@_system_config.__send__(:"#{key.to_s}=", value)
end
end
end
Expand Down

0 comments on commit 880a4a3

Please sign in to comment.