Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Object.__send__ to avoid conflicting method name #2614

Merged
merged 1 commit into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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