Skip to content
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/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(name, root: false, param_name: nil, final: nil, init: nil, requir
# should override "@name".
@root_section = root

@param_name = param_name && param_name.to_sym
@param_name = param_name&.to_sym
@init = init
@required = required
@multi = multi
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/config/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def self.check_unused_section(proxy, conf, plugin_class)
elems = conf.respond_to?(:elements) ? conf.elements : []
elems.each { |e|
next if plugin_class.nil? && Fluent::Config::V1Parser::ELEM_SYMBOLS.include?(e.name) # skip pre-defined non-plugin elements because it doesn't have proxy section
next if e.unused_in && e.unused_in.empty? # the section is used at least once
next if e.unused_in&.empty? # the section is used at least once

if proxy.sections.any? { |name, subproxy| e.name == subproxy.name.to_s || e.name == subproxy.alias.to_s }
e.unused_in = []
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def update_timekeys
chunks = @stage.values
chunks.concat(@queue)
@timekeys = chunks.each_with_object({}) do |chunk, keys|
if chunk.metadata && chunk.metadata.timekey
if chunk.metadata&.timekey
t = chunk.metadata.timekey
keys[t] = keys.fetch(t, 0) + 1
end
Expand Down Expand Up @@ -958,7 +958,7 @@ def backup(chunk_unique_id)
def optimistic_queued?(metadata = nil)
if metadata
n = @queued_num[metadata]
n && n.nonzero?
n&.nonzero?
else
[email protected]?
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def start
log.warn "child process exits with error code", code: status.to_i, status: status.exitstatus, signal: status.termsig
end
c.mutex.synchronize do
(c.writeio && c.writeio.close) rescue nil
(c.readio && c.readio.close) rescue nil
c.writeio&.close rescue nil
c.readio&.close rescue nil
c.pid = c.readio = c.writeio = nil
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ def initialize(sender, server, failure:, connection_manager:, ack_handler:)

@handshake = HandshakeProtocol.new(
log: @log,
hostname: sender.security && sender.security.self_hostname,
shared_key: server.shared_key || (sender.security && sender.security.shared_key) || '',
hostname: sender.security&.self_hostname,
shared_key: server.shared_key || sender.security&.shared_key || '',
password: server.password || '',
username: server.username || '',
)
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def after_shutdown
@output_flush_threads.each do |state|
# to wakeup thread and make it to stop by itself
state.mutex.synchronize {
if state.thread && state.thread.status
if state.thread&.status
state.next_clock = 0
state.cond_var.signal
end
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def rollback_write(chunk_id, update_retry: true)

def try_rollback_write
@dequeued_chunks_mutex.synchronize do
while @dequeued_chunks.first && @dequeued_chunks.first.expired?
while @dequeued_chunks.first&.expired?
info = @dequeued_chunks.shift
if @buffer.takeback_chunk(info.chunk_id)
@rollback_count_metrics.inc
Expand Down Expand Up @@ -1376,7 +1376,7 @@ def submit_flush_once
@output_flush_thread_current_position = (@output_flush_thread_current_position + 1) % @buffer_config.flush_thread_count
state = @output_flush_threads[@output_flush_thread_current_position]
state.mutex.synchronize {
if state.thread && state.thread.status # "run"/"sleep"/"aborting" or false(successfully stop) or nil(killed by exception)
if state.thread&.status # "run"/"sleep"/"aborting" or false(successfully stop) or nil(killed by exception)
state.next_clock = 0
state.cond_var.signal
else
Expand Down Expand Up @@ -1422,7 +1422,7 @@ def enqueue_thread_wait
def flush_thread_wakeup
@output_flush_threads.each do |state|
state.mutex.synchronize {
if state.thread && state.thread.status
if state.thread&.status
state.next_clock = 0
state.cond_var.signal
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def shutdown
@_child_process_mutex.synchronize{ @_child_process_processes.keys }.each do |pid|
process_info = @_child_process_processes[pid]
next if !process_info
process_info.writeio && process_info.writeio.close rescue nil
process_info.writeio&.close rescue nil
end

super
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/http_server/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def query
end

def body
@request.body && @request.body.read
@request.body&.read
end
end
end
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 @@ -38,7 +38,7 @@ def storage_create(usage: '', type: nil, conf: nil, default_type: nil)
end

s = @_storages[usage]
if s && s.running
if s&.running
return s.storage
elsif s
# storage is already created, but not loaded / started
Expand Down
8 changes: 4 additions & 4 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ def test_unwatched_files_should_be_removed
}
)
ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
cleanup_directory(@tmp_dir)
end

Expand Down Expand Up @@ -2540,7 +2540,7 @@ def test_ENOENT_error_after_setup_watcher
assert($log.out.logs.any?{|log| log.include?("stat() for #{path} failed. Continuing without tailing it.\n") },
$log.out.logs.join("\n"))
ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
end

def test_EACCES_error_after_setup_watcher
Expand All @@ -2567,7 +2567,7 @@ def test_EACCES_error_after_setup_watcher
$log.out.logs.join("\n"))
end
ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
if File.exist?("#{@tmp_dir}/noaccess")
FileUtils.chmod(0755, "#{@tmp_dir}/noaccess")
FileUtils.rm_rf("#{@tmp_dir}/noaccess")
Expand All @@ -2589,7 +2589,7 @@ def test_EACCES
end
assert($log.out.logs.any?{|log| log.include?("expand_paths: stat() for #{path} failed with Errno::EACCES. Skip file.\n") })
ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
end

def test_warn_without_directory_permission
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_out_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def create_test_data
assert{ d.instance.dequeued_chunks.empty? }

ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
end

test 'flushed chunk will be taken back after child process unexpectedly exits' do
Expand All @@ -306,7 +306,7 @@ def create_test_data
assert{ File.exist?(expect_path) && File.size(expect_path) == 0 }

ensure
d.instance_shutdown if d && d.instance
d.instance_shutdown if d&.instance
end
end
end