From 46fb4f31633c94ba73d4cd6e439ba2d2bdbf0335 Mon Sep 17 00:00:00 2001 From: Watson Date: Fri, 9 Aug 2024 13:52:47 +0900 Subject: [PATCH] WIP --- lib/fluent/command/ctl.rb | 4 +- lib/fluent/command/plugin_config_formatter.rb | 12 +-- lib/fluent/compat/record_filter_mixin.rb | 4 +- lib/fluent/config/element.rb | 6 +- lib/fluent/config/literal_parser.rb | 10 ++- lib/fluent/config/types.rb | 2 +- lib/fluent/log.rb | 4 +- lib/fluent/match.rb | 8 +- lib/fluent/plugin/buffer/file_chunk.rb | 4 +- lib/fluent/plugin/buffer/memory_chunk.rb | 6 +- lib/fluent/plugin/compressable.rb | 4 +- lib/fluent/plugin/formatter_csv.rb | 8 +- lib/fluent/plugin/formatter_ltsv.rb | 4 +- lib/fluent/plugin/formatter_out_file.rb | 4 +- lib/fluent/plugin/in_http.rb | 6 +- lib/fluent/plugin/in_monitor_agent.rb | 4 +- lib/fluent/plugin/in_syslog.rb | 4 +- lib/fluent/plugin/in_tail.rb | 13 +-- lib/fluent/plugin/parser_csv.rb | 4 +- .../plugin_helper/http_server/server.rb | 1 + lib/fluent/plugin_helper/server.rb | 6 +- lib/fluent/test/output_test.rb | 6 +- test/command/test_fluentd.rb | 13 +-- test/plugin/in_tail/test_fifo.rb | 8 +- test/plugin/in_tail/test_io_handler.rb | 20 +++-- test/plugin/test_buffer_chunk.rb | 4 +- test/plugin/test_buffer_file_chunk.rb | 4 +- test/plugin/test_buffer_file_single_chunk.rb | 4 +- test/plugin/test_buffer_memory_chunk.rb | 4 +- test/plugin/test_filter.rb | 2 + test/plugin/test_filter_grep.rb | 4 +- test/plugin/test_filter_parser.rb | 12 +-- test/plugin/test_in_forward.rb | 18 ++-- test/plugin/test_in_tail.rb | 8 +- test/plugin/test_in_unix.rb | 4 +- test/plugin/test_out_file.rb | 6 +- test/plugin/test_out_secondary_file.rb | 4 +- .../test_output_as_buffered_secondary.rb | 2 + test/plugin_helper/test_retry_state.rb | 4 +- test/plugin_helper/test_server.rb | 82 ++++++++++--------- 40 files changed, 202 insertions(+), 125 deletions(-) diff --git a/lib/fluent/command/ctl.rb b/lib/fluent/command/ctl.rb index f908d40f05..11e59c9a30 100644 --- a/lib/fluent/command/ctl.rb +++ b/lib/fluent/command/ctl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -67,7 +69,7 @@ def initialize(argv = ARGV) end def help_text - text = "\n" + text = +"\n" if Fluent.windows? text << "Usage: #{$PROGRAM_NAME} COMMAND [PID_OR_SVCNAME]\n" else diff --git a/lib/fluent/command/plugin_config_formatter.rb b/lib/fluent/command/plugin_config_formatter.rb index 00d660da0b..7540733d8d 100644 --- a/lib/fluent/command/plugin_config_formatter.rb +++ b/lib/fluent/command/plugin_config_formatter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -79,7 +81,7 @@ def call private def dump_txt(dumped_config) - dumped = "" + dumped = +"" plugin_helpers = dumped_config.delete(:plugin_helpers) if plugin_helpers && !plugin_helpers.empty? dumped << "helpers: #{plugin_helpers.join(',')}\n" @@ -101,7 +103,7 @@ def dump_txt(dumped_config) end def dump_section_txt(base_section, level = 0) - dumped = "" + dumped = +"" indent = " " * level if base_section[:section] sections = [] @@ -135,10 +137,10 @@ def dump_section_txt(base_section, level = 0) end def dump_markdown(dumped_config) - dumped = "" + dumped = +"" plugin_helpers = dumped_config.delete(:plugin_helpers) if plugin_helpers && !plugin_helpers.empty? - dumped = "## Plugin helpers\n\n" + dumped = +"## Plugin helpers\n\n" plugin_helpers.each do |plugin_helper| dumped << "* #{plugin_helper_markdown_link(plugin_helper)}\n" end @@ -156,7 +158,7 @@ def dump_markdown(dumped_config) end def dump_section_markdown(base_section, level = 0) - dumped = "" + dumped = +"" if base_section[:section] sections = [] params = base_section diff --git a/lib/fluent/compat/record_filter_mixin.rb b/lib/fluent/compat/record_filter_mixin.rb index 38a554d8bb..a421f30b2c 100644 --- a/lib/fluent/compat/record_filter_mixin.rb +++ b/lib/fluent/compat/record_filter_mixin.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -21,7 +23,7 @@ def filter_record(tag, time, record) end def format_stream(tag, es) - out = '' + out = +'' es.each {|time,record| tag_temp = tag.dup filter_record(tag_temp, time, record) diff --git a/lib/fluent/config/element.rb b/lib/fluent/config/element.rb index c61eb391cb..e53fb80ea7 100644 --- a/lib/fluent/config/element.rb +++ b/lib/fluent/config/element.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -141,7 +143,7 @@ def check_not_fetched(&block) def to_s(nest = 0) indent = " " * nest nindent = " " * (nest + 1) - out = "" + out = +"" if @arg.nil? || @arg.empty? out << "#{indent}<#{@name}>\n" else @@ -230,7 +232,7 @@ def dump_value(k, v, nindent) end def self.unescape_parameter(v) - result = '' + result = +'' v.each_char { |c| result << LiteralParser.unescape_char(c) } result end diff --git a/lib/fluent/config/literal_parser.rb b/lib/fluent/config/literal_parser.rb index 5664986481..f34066dff8 100644 --- a/lib/fluent/config/literal_parser.rb +++ b/lib/fluent/config/literal_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -228,8 +230,8 @@ def scan_json(is_array) # Yajl does not raise ParseError for incomplete json string, like '[1', '{"h"', '{"h":' or '{"h1":1' # This is the reason to use JSON module. - buffer = (is_array ? "[" : "{") - line_buffer = "" + buffer = +(is_array ? "[" : "{") + line_buffer = +"" until result char = getch @@ -252,7 +254,7 @@ def scan_json(is_array) # ignore comment char end buffer << line_buffer + "\n" - line_buffer = "" + line_buffer = +"" else # '#' is a char in json string line_buffer << char @@ -263,7 +265,7 @@ def scan_json(is_array) if char == "\n" buffer << line_buffer + "\n" - line_buffer = "" + line_buffer = +"" next end diff --git a/lib/fluent/config/types.rb b/lib/fluent/config/types.rb index 9c9ba89c8d..cc3f4a1b2d 100644 --- a/lib/fluent/config/types.rb +++ b/lib/fluent/config/types.rb @@ -183,7 +183,7 @@ def self.enum_value(val, opts = {}, name = nil) value else case type - when :string then value.to_s.force_encoding(Encoding::UTF_8) + when :string then (+(value.to_s)).force_encoding(Encoding::UTF_8) when :integer then INTEGER_TYPE.call(value, opts, name) when :float then FLOAT_TYPE.call(value, opts, name) when :size then Config.size_value(value, opts, name) diff --git a/lib/fluent/log.rb b/lib/fluent/log.rb index f8175fd911..69d632870a 100644 --- a/lib/fluent/log.rb +++ b/lib/fluent/log.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -550,7 +552,7 @@ def get_worker_id(type) def event(level, args) time = Time.now - message = @optional_header ? @optional_header.dup : '' + message = @optional_header ? @optional_header.dup : +'' map = @optional_attrs ? @optional_attrs.dup : {} args.each {|a| if a.is_a?(Hash) diff --git a/lib/fluent/match.rb b/lib/fluent/match.rb index 7b6c076adc..a8831c94b9 100644 --- a/lib/fluent/match.rb +++ b/lib/fluent/match.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -43,7 +45,7 @@ def initialize(pat) end stack = [] - regex = [''] + regex = [+''] escape = false dot = false @@ -105,7 +107,7 @@ def initialize(pat) elsif c == "{" # or stack.push [] - regex.push '' + regex.push(+'') elsif c == "}" && !stack.empty? stack.last << regex.pop @@ -113,7 +115,7 @@ def initialize(pat) elsif c == "," && !stack.empty? stack.last << regex.pop - regex.push '' + regex.push(+'') elsif /[a-zA-Z0-9_]/.match?(c) regex.last << c diff --git a/lib/fluent/plugin/buffer/file_chunk.rb b/lib/fluent/plugin/buffer/file_chunk.rb index 7930574a58..7373e8b68d 100644 --- a/lib/fluent/plugin/buffer/file_chunk.rb +++ b/lib/fluent/plugin/buffer/file_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -24,7 +26,7 @@ class Buffer class FileChunk < Chunk class FileChunkError < StandardError; end - BUFFER_HEADER = "\xc1\x00".force_encoding(Encoding::ASCII_8BIT).freeze + BUFFER_HEADER = (+"\xc1\x00").force_encoding(Encoding::ASCII_8BIT).freeze ### buffer path user specified : /path/to/directory/user_specified_prefix.*.log ### buffer chunk path : /path/to/directory/user_specified_prefix.b513b61c9791029c2513b61c9791029c2.log diff --git a/lib/fluent/plugin/buffer/memory_chunk.rb b/lib/fluent/plugin/buffer/memory_chunk.rb index 556c8c8a3d..ebd4a8a633 100644 --- a/lib/fluent/plugin/buffer/memory_chunk.rb +++ b/lib/fluent/plugin/buffer/memory_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -22,7 +24,7 @@ class Buffer class MemoryChunk < Chunk def initialize(metadata, compress: :text) super - @chunk = ''.force_encoding(Encoding::ASCII_8BIT) + @chunk = (+'').force_encoding(Encoding::ASCII_8BIT) @chunk_bytes = 0 @adding_bytes = 0 @adding_size = 0 @@ -68,7 +70,7 @@ def empty? def purge super - @chunk = ''.force_encoding("ASCII-8BIT") + @chunk = (+'').force_encoding("ASCII-8BIT") @chunk_bytes = @size = @adding_bytes = @adding_size = 0 true end diff --git a/lib/fluent/plugin/compressable.rb b/lib/fluent/plugin/compressable.rb index aa242478fe..73fcf94d21 100644 --- a/lib/fluent/plugin/compressable.rb +++ b/lib/fluent/plugin/compressable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -57,7 +59,7 @@ def decompress(compressed_data = nil, output_io: nil, input_io: nil) def string_decompress(compressed_data) io = StringIO.new(compressed_data) - out = '' + out = +'' loop do gz = Zlib::GzipReader.new(io) out << gz.read diff --git a/lib/fluent/plugin/formatter_csv.rb b/lib/fluent/plugin/formatter_csv.rb index 74760a1df7..6bc33db816 100644 --- a/lib/fluent/plugin/formatter_csv.rb +++ b/lib/fluent/plugin/formatter_csv.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -50,13 +52,13 @@ def configure(conf) end @generate_opts = {col_sep: @delimiter, force_quotes: @force_quotes, headers: @fields, - row_sep: @add_newline ? :auto : "".force_encoding(Encoding::ASCII_8BIT)} + row_sep: @add_newline ? :auto : (+"").force_encoding(Encoding::ASCII_8BIT)} # Cache CSV object per thread to avoid internal state sharing @cache = {} end def format(tag, time, record) - csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) + csv = (@cache[Thread.current] ||= CSV.new((+"").force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) line = (csv << record).string.dup # Need manual cleanup because CSV writer doesn't provide such method. csv.rewind @@ -65,7 +67,7 @@ def format(tag, time, record) end def format_with_nested_fields(tag, time, record) - csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) + csv = (@cache[Thread.current] ||= CSV.new((+"").force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) values = @accessors.map { |a| a.call(record) } line = (csv << values).string.dup # Need manual cleanup because CSV writer doesn't provide such method. diff --git a/lib/fluent/plugin/formatter_ltsv.rb b/lib/fluent/plugin/formatter_ltsv.rb index 76100bb91b..1bf054ecdf 100644 --- a/lib/fluent/plugin/formatter_ltsv.rb +++ b/lib/fluent/plugin/formatter_ltsv.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -31,7 +33,7 @@ class LabeledTSVFormatter < Formatter config_param :add_newline, :bool, default: true def format(tag, time, record) - formatted = "" + formatted = +"" record.each do |label, value| formatted << @delimiter if formatted.length.nonzero? formatted << "#{label}#{@label_delimiter}#{value.to_s.gsub(@delimiter, @replacement)}" diff --git a/lib/fluent/plugin/formatter_out_file.rb b/lib/fluent/plugin/formatter_out_file.rb index 364303000a..bb853d5150 100644 --- a/lib/fluent/plugin/formatter_out_file.rb +++ b/lib/fluent/plugin/formatter_out_file.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -43,7 +45,7 @@ def configure(conf) end def format(tag, time, record) - header = '' + header = +'' header << "#{@timef.format(time)}#{@delimiter}" if @output_time header << "#{tag}#{@delimiter}" if @output_tag "#{header}#{Yajl.dump(record)}#{@newline}" diff --git a/lib/fluent/plugin/in_http.rb b/lib/fluent/plugin/in_http.rb index 6385a80a79..e141a13bca 100644 --- a/lib/fluent/plugin/in_http.rb +++ b/lib/fluent/plugin/in_http.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -56,7 +58,7 @@ class HttpInput < Input helpers :parser, :compat_parameters, :event_loop, :server - EMPTY_GIF_IMAGE = "GIF89a\u0001\u0000\u0001\u0000\x80\xFF\u0000\xFF\xFF\xFF\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;".force_encoding("UTF-8") + EMPTY_GIF_IMAGE = (+"GIF89a\u0001\u0000\u0001\u0000\x80\xFF\u0000\xFF\xFF\xFF\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;").force_encoding("UTF-8") desc 'The port to listen to.' config_param :port, :integer, default: 9880 @@ -375,7 +377,7 @@ def on_read(data) end def on_message_begin - @body = '' + @body = +'' end def on_headers_complete(headers) diff --git a/lib/fluent/plugin/in_monitor_agent.rb b/lib/fluent/plugin/in_monitor_agent.rb index f41c1a0bce..0654f7b7d2 100644 --- a/lib/fluent/plugin/in_monitor_agent.rb +++ b/lib/fluent/plugin/in_monitor_agent.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -102,7 +104,7 @@ def render_json(obj, code: 200, pretty_json: nil) def render_ltsv(obj, code: 200) normalized = JSON.parse(obj.to_json) - text = '' + text = +'' normalized.each do |hash| row = [] hash.each do |k, v| diff --git a/lib/fluent/plugin/in_syslog.rb b/lib/fluent/plugin/in_syslog.rb index 28ad1c5dd9..b4d38e2227 100644 --- a/lib/fluent/plugin/in_syslog.rb +++ b/lib/fluent/plugin/in_syslog.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -187,7 +189,7 @@ def start_tcp_server(tls: false) send_keepalive_packet: @send_keepalive_packet ) do |conn| conn.data do |data| - buffer = conn.buffer + buffer = +conn.buffer buffer << data pos = 0 if octet_count_frame diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index 852f2723bd..eb3ea884e6 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -719,7 +721,7 @@ def receive_lines(lines, tail_watcher) def convert_line_to_event(line, es, tail_watcher) begin - line.chomp! # remove \n + line = line.chomp # remove \n @parser.parse(line) { |time, record| if time && record record[@path_key] ||= tail_watcher.path unless @path_key.nil? @@ -771,13 +773,13 @@ def parse_multilines(lines, tail_watcher) end } else - lb ||= '' + lb ||= +'' lines.each do |line| lb << line @parser.parse(lb) { |time, record| if time && record convert_line_to_event(lb, es, tail_watcher) - lb = '' + lb = +'' end } end @@ -1010,7 +1012,7 @@ def initialize(from_encoding, encoding, log, max_line_size=nil) @from_encoding = from_encoding @encoding = encoding @need_enc = from_encoding != encoding - @buffer = ''.force_encoding(from_encoding) + @buffer = (+'').force_encoding(from_encoding) @eol = "\n".encode(from_encoding).freeze @max_line_size = max_line_size @skip_current_line = false @@ -1032,6 +1034,7 @@ def <<(chunk) # quad-byte encoding to IO#readpartial as the second arguments results in an # assertion failure on Ruby < 2.4.0 for unknown reasons. orig_encoding = chunk.encoding + chunk = chunk.frozen? ? chunk.dup : chunk chunk.force_encoding(from_encoding) @buffer << chunk # Thus the encoding needs to be reverted back here @@ -1118,7 +1121,7 @@ def initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, @receive_lines = receive_lines @open_on_every_update = open_on_every_update @fifo = FIFO.new(from_encoding || Encoding::ASCII_8BIT, encoding || Encoding::ASCII_8BIT, log, max_line_size) - @iobuf = ''.force_encoding('ASCII-8BIT') + @iobuf = (+'').force_encoding('ASCII-8BIT') @lines = [] @io = nil @notify_mutex = Mutex.new diff --git a/lib/fluent/plugin/parser_csv.rb b/lib/fluent/plugin/parser_csv.rb index 21d89df874..2b3916f372 100644 --- a/lib/fluent/plugin/parser_csv.rb +++ b/lib/fluent/plugin/parser_csv.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -63,7 +65,7 @@ def parse_fast(text, &block) # This method avoids the overhead of CSV.parse_line for typical patterns def parse_fast_internal(text) record = {} - text.chomp! + text = text.chomp return record if text.empty? diff --git a/lib/fluent/plugin_helper/http_server/server.rb b/lib/fluent/plugin_helper/http_server/server.rb index 549db76cc8..77fadc1e47 100644 --- a/lib/fluent/plugin_helper/http_server/server.rb +++ b/lib/fluent/plugin_helper/http_server/server.rb @@ -78,6 +78,7 @@ def stop HttpServer::Methods::ALL.map { |e| e.downcase.to_sym }.each do |name| define_method(name) do |path, app = nil, &block| unless path.end_with?('/') + path = path.frozen? ? path.dup : path path << '/' end diff --git a/lib/fluent/plugin_helper/server.rb b/lib/fluent/plugin_helper/server.rb index eecee5ae7e..b5c80b9e18 100644 --- a/lib/fluent/plugin_helper/server.rb +++ b/lib/fluent/plugin_helper/server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -465,7 +467,7 @@ class TCPCallbackSocket < CallbackSocket def initialize(sock) super("tcp", sock, ENABLED_EVENTS) @peeraddr = (@sock.peeraddr rescue PEERADDR_FAILED) - @buffer = '' + @buffer = +'' end def write(data) @@ -675,7 +677,7 @@ def initialize(sock, context, socket_option_setter, close_callback, log, under_p socket_option_setter.call(sock) @_handler_socket = OpenSSL::SSL::SSLSocket.new(sock, context) @_handler_socket.sync_close = true - @_handler_write_buffer = ''.force_encoding('ascii-8bit') + @_handler_write_buffer = (+'').force_encoding('ascii-8bit') @_handler_accepted = false super(@_handler_socket) diff --git a/lib/fluent/test/output_test.rb b/lib/fluent/test/output_test.rb index bb18884dc2..e5571096fe 100644 --- a/lib/fluent/test/output_test.rb +++ b/lib/fluent/test/output_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Fluentd # @@ -116,7 +118,7 @@ def emit(record, time=EventTime.now) end def expect_format(str) - (@expected_buffer ||= '') << str + (@expected_buffer ||= +'') << str end def run(&block) @@ -124,7 +126,7 @@ def run(&block) super { block.call if block - buffer = '' + buffer = +'' lines = {} # v0.12 TimeSlicedOutput doesn't call #format_stream @entries.each do |time, record| diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb index c6bd88d857..2ecbd75773 100644 --- a/test/command/test_fluentd.rb +++ b/test/command/test_fluentd.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' # require 'fluent/command/fluentd' @@ -132,7 +134,7 @@ def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: matched = false matched_wrongly = false assert_error_msg = "" - stdio_buf = "" + stdio_buf = +"" begin execute_command(cmdline, @tmp_dir, env) do |pid, stdout| begin @@ -197,6 +199,7 @@ def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: lines.any?{|line| line.include?(ptn) } end if matched_wrongly + assert_error_msg = assert_error_msg.frozen? ? assert_error_msg.dup : assert_error_msg assert_error_msg << "\n" unless assert_error_msg.empty? assert_error_msg << "pattern exists in logs wrongly: #{ptn}" end @@ -214,7 +217,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20) matched = false running = false assert_error_msg = "failed to start correctly" - stdio_buf = "" + stdio_buf = +"" begin execute_command(cmdline) do |pid, stdout| begin @@ -532,7 +535,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20) sub_test_case 'configuration to load plugin file with syntax error' do test 'failed to start' do - script = "require 'fluent/plugin/input'\n" + script = +"require 'fluent/plugin/input'\n" script << "module Fluent::Plugin\n" script << " class BuggyInput < Input\n" script << " Fluent::Plugin.register_input('buggy', self)\n" @@ -566,7 +569,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20) sub_test_case 'configuration to load plugin which raises unrecoverable error in #start' do test 'failed to start' do - script = "require 'fluent/plugin/input'\n" + script = +"require 'fluent/plugin/input'\n" script << "require 'fluent/error'\n" script << "module Fluent::Plugin\n" script << " class CrashingInput < Input\n" @@ -701,7 +704,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20) end test 'failed to start workers when configured plugins do not support multi worker configuration' do - script = "require 'fluent/plugin/input'\n" + script = +"require 'fluent/plugin/input'\n" script << "module Fluent::Plugin\n" script << " class SingleInput < Input\n" script << " Fluent::Plugin.register_input('single', self)\n" diff --git a/test/plugin/in_tail/test_fifo.rb b/test/plugin/in_tail/test_fifo.rb index ebead83b92..aad9c6b6d9 100644 --- a/test/plugin/in_tail/test_fifo.rb +++ b/test/plugin/in_tail/test_fifo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../../helper' require 'fluent/plugin/in_tail' @@ -57,7 +59,7 @@ class IntailFIFO < Test::Unit::TestCase lines = [] fifo.read_lines(lines) assert_equal Encoding::ASCII_8BIT, lines[0].encoding - assert_equal ["てすと\n", "てすと\n", "てすと\n"].map { |e| e.force_encoding(Encoding::ASCII_8BIT) }, lines + assert_equal ["てすと\n", "てすと\n", "てすと\n"].map { |e| (+e).force_encoding(Encoding::ASCII_8BIT) }, lines end test 'replaces character with ? when convert error happens' do @@ -67,7 +69,7 @@ class IntailFIFO < Test::Unit::TestCase lines = [] fifo.read_lines(lines) assert_equal Encoding::ASCII_8BIT, lines[0].encoding - assert_equal ["???\n", "???\n", "???\n"].map { |e| e.force_encoding(Encoding::ASCII_8BIT) }, lines + assert_equal ["???\n", "???\n", "???\n"].map { |e| (+e).force_encoding(Encoding::ASCII_8BIT) }, lines end end @@ -121,7 +123,7 @@ class IntailFIFO < Test::Unit::TestCase lines = [] input_texts.each do |text| - fifo << text.force_encoding(Encoding::ASCII_8BIT) + fifo << (+text).force_encoding(Encoding::ASCII_8BIT) fifo.read_lines(lines) # The size of remaining buffer (i.e. a line still not having EOL) must not exceed max_line_size. assert { fifo.buffer.bytesize <= max_line_size } diff --git a/test/plugin/in_tail/test_io_handler.rb b/test/plugin/in_tail/test_io_handler.rb index 5dd37dc4b8..ca8e4a4d77 100644 --- a/test/plugin/in_tail/test_io_handler.rb +++ b/test/plugin/in_tail/test_io_handler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../../helper' require 'fluent/plugin/in_tail' @@ -40,13 +42,13 @@ def create_watcher update_pos = 0 stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { 0 } stub(pe).update_pos { |val| update_pos = val } pe end - returned_lines = '' + returned_lines = +'' r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: false, metrics: @metrics) do |lines, _watcher| returned_lines << lines.join true @@ -72,13 +74,13 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { 0 } stub(pe).update_pos { |val| update_pos = val } pe end - returned_lines = '' + returned_lines = +'' r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: true, metrics: @metrics) do |lines, _watcher| returned_lines << lines.join true @@ -103,7 +105,7 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { 0 } stub(pe).update_pos { |val| update_pos = val } pe @@ -130,7 +132,7 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { 0 } stub(pe).update_pos { |val| update_pos = val } pe @@ -163,7 +165,7 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos {0} stub(pe).update_pos { |val| update_pos = val } pe @@ -191,7 +193,7 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { pos } stub(pe).update_pos { |val| pos = val } pe @@ -242,7 +244,7 @@ def create_watcher watcher = create_watcher stub(watcher).pe do - pe = 'position_file' + pe = +'position_file' stub(pe).read_pos { pos } stub(pe).update_pos { |val| pos = val } pe diff --git a/test/plugin/test_buffer_chunk.rb b/test/plugin/test_buffer_chunk.rb index 535b0acd1a..af235d44a3 100644 --- a/test/plugin/test_buffer_chunk.rb +++ b/test/plugin/test_buffer_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/buffer/chunk' @@ -83,7 +85,7 @@ class TestChunk < Fluent::Plugin::Buffer::Chunk attr_accessor :data def initialize(meta) super - @data = '' + @data = +'' end def size @data.size diff --git a/test/plugin/test_buffer_file_chunk.rb b/test/plugin/test_buffer_file_chunk.rb index 00bd4fc153..72a1509ba8 100644 --- a/test/plugin/test_buffer_file_chunk.rb +++ b/test/plugin/test_buffer_file_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/buffer/file_chunk' require 'fluent/plugin/compressable' @@ -212,7 +214,7 @@ def gen_chunk_path(prefix, unique_id) end test 'has its contents in binary (ascii-8bit)' do - data1 = "aaa bbb ccc".force_encoding('utf-8') + data1 = (+"aaa bbb ccc").force_encoding('utf-8') @c.append([data1]) @c.commit assert_equal Encoding::ASCII_8BIT, @c.instance_eval{ @chunk.external_encoding } diff --git a/test/plugin/test_buffer_file_single_chunk.rb b/test/plugin/test_buffer_file_single_chunk.rb index db96092b3b..aa3d29d659 100644 --- a/test/plugin/test_buffer_file_single_chunk.rb +++ b/test/plugin/test_buffer_file_single_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/buffer/file_single_chunk' require 'fluent/plugin/compressable' @@ -178,7 +180,7 @@ def gen_chunk_path(prefix, unique_id) end test 'has its contents in binary (ascii-8bit)' do - data1 = "aaa bbb ccc".force_encoding('utf-8') + data1 = (+"aaa bbb ccc").force_encoding('utf-8') @c.append([data1]) @c.commit assert_equal Encoding::ASCII_8BIT, @c.instance_eval{ @chunk.external_encoding } diff --git a/test/plugin/test_buffer_memory_chunk.rb b/test/plugin/test_buffer_memory_chunk.rb index 03f2dda9f1..4a216257d7 100644 --- a/test/plugin/test_buffer_memory_chunk.rb +++ b/test/plugin/test_buffer_memory_chunk.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/buffer/memory_chunk' require 'fluent/plugin/compressable' @@ -82,7 +84,7 @@ class BufferMemoryChunkTest < Test::Unit::TestCase end test 'has its contents in binary (ascii-8bit)' do - data1 = "aaa bbb ccc".force_encoding('utf-8') + data1 = (+"aaa bbb ccc").force_encoding('utf-8') @c.append([data1]) @c.commit assert_equal Encoding::ASCII_8BIT, @c.instance_eval{ @chunk.encoding } diff --git a/test/plugin/test_filter.rb b/test/plugin/test_filter.rb index 322258942a..b97109017a 100644 --- a/test/plugin/test_filter.rb +++ b/test/plugin/test_filter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/filter' require 'fluent/event' diff --git a/test/plugin/test_filter_grep.rb b/test/plugin/test_filter_grep.rb index 211a50c6c5..eac6840ec2 100644 --- a/test/plugin/test_filter_grep.rb +++ b/test/plugin/test_filter_grep.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/filter_grep' require 'fluent/test/driver/filter' @@ -329,7 +331,7 @@ def messages test "don't raise an exception" do assert_nothing_raised { - filter(%[regexp1 message WARN], ["\xff".force_encoding('UTF-8')]) + filter(%[regexp1 message WARN], [(+"\xff").force_encoding('UTF-8')]) } end end diff --git a/test/plugin/test_filter_parser.rb b/test/plugin/test_filter_parser.rb index 45df597400..f436544406 100644 --- a/test/plugin/test_filter_parser.rb +++ b/test/plugin/test_filter_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'timecop' require 'fluent/test/driver/filter' @@ -575,7 +577,7 @@ def test_filter_invalid_time_data replace_invalid_sequence true ] def test_filter_invalid_byte - invalid_utf8 = "\xff".force_encoding('UTF-8') + invalid_utf8 = (+"\xff").force_encoding('UTF-8') d = create_driver(CONFIG_NOT_REPLACE) d.run do @@ -594,7 +596,7 @@ def test_filter_invalid_byte filtered = d.filtered assert_equal 1, filtered.length assert_nil filtered[0][1]['data'] - assert_equal '?'.force_encoding('UTF-8'), filtered[0][1]['message'] + assert_equal (+'?').force_encoding('UTF-8'), filtered[0][1]['message'] d = create_driver(CONFIG_INVALID_BYTE + %[reserve_data yes]) assert_nothing_raised { @@ -605,9 +607,9 @@ def test_filter_invalid_byte filtered = d.filtered assert_equal 1, filtered.length assert_equal invalid_utf8, filtered[0][1]['data'] - assert_equal '?'.force_encoding('UTF-8'), filtered[0][1]['message'] + assert_equal (+'?').force_encoding('UTF-8'), filtered[0][1]['message'] - invalid_ascii = "\xff".force_encoding('US-ASCII') + invalid_ascii = (+"\xff").force_encoding('US-ASCII') d = create_driver(CONFIG_INVALID_BYTE) assert_nothing_raised { d.run do @@ -617,7 +619,7 @@ def test_filter_invalid_byte filtered = d.filtered assert_equal 1, filtered.length assert_nil filtered[0][1]['data'] - assert_equal '?'.force_encoding('US-ASCII'), filtered[0][1]['message'] + assert_equal (+'?').force_encoding('US-ASCII'), filtered[0][1]['message'] end CONFIG_NOT_IGNORE = %[ diff --git a/test/plugin/test_in_forward.rb b/test/plugin/test_in_forward.rb index bce0cdc857..493f4d5cd2 100644 --- a/test/plugin/test_in_forward.rb +++ b/test/plugin/test_in_forward.rb @@ -397,7 +397,7 @@ def create_driver(conf=base_config) ] d.run(expect_records: records.length, timeout: 20) do - entries = '' + entries = +'' records.each {|_tag, _time, record| packer(entries).write([_time, record]).flush } @@ -425,7 +425,7 @@ def create_driver(conf=base_config) ] @d.run(expect_records: records.length, timeout: 20) do - entries = '' + entries = +'' records.each {|_tag, _time, record| packer(entries).write([_time, record]).flush } @@ -457,7 +457,7 @@ def create_driver(conf=base_config) ] d.run(expect_records: records.length, timeout: 20) do - entries = '' + entries = +'' records.each {|tag, _time, record| packer(entries).write([_time, record]).flush } @@ -493,7 +493,7 @@ def create_driver(conf=base_config) # These entries are skipped entries << ['invalid time', {'a' => 3}] << [time, 'invalid record'] - packed_entries = '' + packed_entries = +'' entries.each { |_time, record| packer(packed_entries).write([_time, record]).flush } @@ -518,7 +518,7 @@ def create_driver(conf=base_config) ] # create compressed entries - entries = '' + entries = +'' events.each do |_tag, _time, record| v = [_time, record].to_msgpack entries << compress(v) @@ -545,7 +545,7 @@ def create_driver(conf=base_config) ] # create compressed entries - entries = '' + entries = +'' events.each do |_tag, _time, record| v = [_time, record].to_msgpack entries << compress(v) @@ -988,7 +988,7 @@ def unpacker # '' : socket is disconnected without any data # nil: socket read timeout def read_data(io, timeout, &block) - res = '' + res = +'' select_timeout = 0.5 clock_id = Process::CLOCK_MONOTONIC_RAW rescue Process::CLOCK_MONOTONIC timeout_at = Process.clock_gettime(clock_id) + timeout @@ -999,7 +999,7 @@ def read_data(io, timeout, &block) if IO.select([io], nil, nil, select_timeout) io_activated = true buf = io.readpartial(2048) - res ||= '' + res ||= +'' res << buf break if block.call(res) @@ -1129,7 +1129,7 @@ def send_data(data, try_to_receive_response: false, response_timeout: 5, auth: f ) test 'packed forward protocol' do |keys| execute_test_with_source_hostname_key(*keys) { |events| - entries = '' + entries = +'' events.each { |tag, time, record| Fluent::MessagePackFactory.msgpack_packer(entries).write([time, record]).flush } diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index f9e3b1a0c5..af82915231 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/test/driver/input' require 'fluent/plugin/in_tail' @@ -1165,7 +1167,7 @@ def test_from_encoding "encoding" => "utf-8" }) d = create_driver(conf) - cp932_message = "\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932) + cp932_message = (+"\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7").force_encoding(Encoding::CP932) utf8_message = cp932_message.encode(Encoding::UTF_8) d.run(expect_emits: 1) do @@ -1375,8 +1377,8 @@ def test_multiline_from_encoding_of_flushed_record }) d = create_driver(conf) - cp932_message = "s \x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932) - utf8_message = "\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".encode(Encoding::UTF_8, Encoding::CP932) + cp932_message = (+"s \x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7").force_encoding(Encoding::CP932) + utf8_message = (+"\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7").encode(Encoding::UTF_8, Encoding::CP932) d.run(expect_emits: 1) do Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "w:cp932") { |f| f.puts cp932_message diff --git a/test/plugin/test_in_unix.rb b/test/plugin/test_in_unix.rb index abc6f3ea6a..98968fe712 100644 --- a/test/plugin/test_in_unix.rb +++ b/test/plugin/test_in_unix.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/test/driver/input' require 'fluent/plugin/in_unix' @@ -115,7 +117,7 @@ def test_packed_forward ] @d.run(expect_records: records.length, timeout: 20) do - entries = '' + entries = +'' records.each {|_tag, _time, record| packer(entries).write([_time, record]).flush } diff --git a/test/plugin/test_out_file.rb b/test/plugin/test_out_file.rb index 8b6ab161d0..ba2ea561da 100644 --- a/test/plugin/test_out_file.rb +++ b/test/plugin/test_out_file.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/test/driver/output' require 'fluent/plugin/out_file' @@ -400,7 +402,7 @@ def create_driver(conf = CONFIG, opts = {}) def check_gzipped_result(path, expect) # Zlib::GzipReader has a bug of concatenated file: https://bugs.ruby-lang.org/issues/9790 # Following code from https://www.ruby-forum.com/topic/971591#979520 - result = '' + result = +'' File.open(path, "rb") { |io| loop do gzr = Zlib::GzipReader.new(StringIO.new(io.read)) @@ -589,7 +591,7 @@ def parse_system(text) d.instance.last_written_path } - log_file_name = "out_file_test.20110102.log" + log_file_name = +"out_file_test.20110102.log" if compression log_file_name << ".gz" end diff --git a/test/plugin/test_out_secondary_file.rb b/test/plugin/test_out_secondary_file.rb index 05091b2853..c5f6d5e315 100644 --- a/test/plugin/test_out_secondary_file.rb +++ b/test/plugin/test_out_secondary_file.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'time' require 'fileutils' @@ -113,7 +115,7 @@ def create_driver(conf = CONFIG, primary = create_primary) def check_gzipped_result(path, expect) # Zlib::GzipReader has a bug of concatenated file: https://bugs.ruby-lang.org/issues/9790 # Following code from https://www.ruby-forum.com/topic/971591#979520 - result = "" + result = +"" waiting(10) do # we can expect that GzipReader#read can wait unflushed raw data of `io` on disk File.open(path, "rb") { |io| diff --git a/test/plugin/test_output_as_buffered_secondary.rb b/test/plugin/test_output_as_buffered_secondary.rb index c908daf74b..954c2ca6ee 100644 --- a/test/plugin/test_output_as_buffered_secondary.rb +++ b/test/plugin/test_output_as_buffered_secondary.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin/output' require 'fluent/plugin/buffer' diff --git a/test/plugin_helper/test_retry_state.rb b/test/plugin_helper/test_retry_state.rb index b61e5e35db..6ab2382353 100644 --- a/test/plugin_helper/test_retry_state.rb +++ b/test/plugin_helper/test_retry_state.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin_helper/retry_state' require 'fluent/plugin/base' @@ -965,7 +967,7 @@ def ==(obj) trying_count = 1000 # just for avoiding infinite loop retry_records = [] - msg = "" + msg = +"" s = @d.retry_state_create( :t15, :exponential_backoff, data[:wait], data[:timeout], diff --git a/test/plugin_helper/test_server.rb b/test/plugin_helper/test_server.rb index 347938eca3..8603af5b2e 100644 --- a/test/plugin_helper/test_server.rb +++ b/test/plugin_helper/test_server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../helper' require 'fluent/plugin_helper/server' require 'fluent/plugin_helper/cert_option' # to create certs for tests @@ -393,7 +395,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'creates a tcp server just to read data' do - received = "" + received = +"" @d.server_create_tcp(:s, @port) do |data| received << data end @@ -408,7 +410,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'creates a tcp server to read and write data' do - received = "" + received = +"" responses = [] @d.server_create_tcp(:s, @port) do |data, conn| received << data @@ -429,7 +431,7 @@ class Dummy < Fluent::Plugin::TestBase test 'creates a tcp server to read and write data using IPv6' do omit "IPv6 unavailable here" unless ipv6_enabled? - received = "" + received = +"" responses = [] @d.server_create_tcp(:s, @port, bind: "::1") do |data, conn| received << data @@ -448,7 +450,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'does not resolve name of client address in default' do - received = "" + received = +"" sources = [] @d.server_create_tcp(:s, @port) do |data, conn| received << data @@ -467,7 +469,7 @@ class Dummy < Fluent::Plugin::TestBase test 'does resolve name of client address if resolve_name is true' do hostname = Socket.getnameinfo([nil, nil, nil, "127.0.0.1"])[0] - received = "" + received = +"" sources = [] @d.server_create_tcp(:s, @port, resolve_name: true) do |data, conn| received << data @@ -488,7 +490,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'raises error if plugin registers data callback for connection object from #server_create' do - received = "" + received = +"" errors = [] @d.server_create_tcp(:s, @port) do |data, conn| received << data @@ -508,7 +510,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'can call write_complete callback if registered' do - buffer = "" + buffer = +"" lines = [] responses = [] response_completes = [] @@ -539,7 +541,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'can call close callback if registered' do - buffer = "" + buffer = +"" lines = [] callback_results = [] @d.server_create_tcp(:s, @port) do |data, conn| @@ -594,7 +596,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'creates a udp server just to read data' do - received = "" + received = +"" @d.server_create_udp(:s, @port, max_bytes: 128) do |data| received << data end @@ -612,7 +614,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'creates a udp server to read and write data' do - received = "" + received = +"" responses = [] @d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock| received << data @@ -652,7 +654,7 @@ class Dummy < Fluent::Plugin::TestBase test 'creates a udp server to read and write data using IPv6' do omit "IPv6 unavailable here" unless ipv6_enabled? - received = "" + received = +"" responses = [] @d.server_create_udp(:s, @port, bind: "::1", max_bytes: 128) do |data, sock| received << data @@ -680,7 +682,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'does not resolve name of client address in default' do - received = "" + received = +"" sources = [] @d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock| received << data @@ -700,7 +702,7 @@ class Dummy < Fluent::Plugin::TestBase test 'does resolve name of client address if resolve_name is true' do hostname = Socket.getnameinfo([nil, nil, nil, "127.0.0.1"])[0] - received = "" + received = +"" sources = [] @d.server_create_udp(:s, @port, resolve_name: true, max_bytes: 128) do |data, sock| received << data @@ -718,7 +720,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'raises error if plugin registers data callback for connection object from #server_create' do - received = "" + received = +"" errors = [] @d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock| received << data @@ -740,7 +742,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'raise error if plugin registers write_complete callback for udp' do - received = "" + received = +"" errors = [] @d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock| received << data @@ -762,7 +764,7 @@ class Dummy < Fluent::Plugin::TestBase end test 'raises error if plugin registers close callback for udp' do - received = "" + received = +"" errors = [] @d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock| received << data @@ -995,7 +997,7 @@ def assert_certificate(cert, expected_extensions) generate_cert_digest: :sha256, } - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: tls_options) do |data, conn| received << data end @@ -1034,7 +1036,7 @@ def assert_certificate(cert, expected_extensions) private_key_path: private_key_path, } tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: tls_options) do |data, conn| received << data end @@ -1069,7 +1071,7 @@ def assert_certificate(cert, expected_extensions) generate_private_key_length: 2048, } tls_options[:ca_private_key_passphrase] = ca_key_passphrase if ca_key_passphrase - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: tls_options) do |data, conn| received << data end @@ -1108,7 +1110,7 @@ def assert_certificate(cert, expected_extensions) private_key_path: private_key_path, } tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: tls_options) do |data, conn| received << data end @@ -1138,7 +1140,7 @@ def assert_certificate(cert, expected_extensions) private_key_path: private_key_path, } tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: tls_options) do |data, conn| received << data end @@ -1162,7 +1164,7 @@ def assert_certificate(cert, expected_extensions) @d.configure(conf); @d.start; @d.after_start - received = "" + received = +"" @d.server_create_tls(:s, @port) do |data, conn| received << data end @@ -1197,7 +1199,7 @@ def assert_certificate(cert, expected_extensions) @d.configure(conf); @d.start; @d.after_start - received = "" + received = +"" @d.server_create_tls(:s, @port) do |data, conn| received << data end @@ -1232,7 +1234,7 @@ def assert_certificate(cert, expected_extensions) @d.configure(conf); @d.start; @d.after_start - received = "" + received = +"" @d.server_create_tls(:s, @port) do |data, conn| received << data end @@ -1265,7 +1267,7 @@ def assert_certificate(cert, expected_extensions) @d.configure(conf); @d.start; @d.after_start - received = "" + received = +"" @d.server_create_tls(:s, @port) do |data, conn| received << data end @@ -1296,7 +1298,7 @@ def assert_certificate(cert, expected_extensions) @d.configure(conf); @d.start; @d.after_start - received = "" + received = +"" @d.server_create_tls(:s, @port) do |data, conn| received << data end @@ -1380,7 +1382,7 @@ def assert_certificate(cert, expected_extensions) end test 'creates a tls server just to read data' do - received = "" + received = +"" @d.server_create_tls(:s, @port, tls_options: @tls_options) do |data, conn| received << data end @@ -1396,7 +1398,7 @@ def assert_certificate(cert, expected_extensions) end test 'creates a tls server to read and write data' do - received = "" + received = +"" responses = [] @d.server_create_tls(:s, @port, tls_options: @tls_options) do |data, conn| received << data @@ -1419,7 +1421,7 @@ def assert_certificate(cert, expected_extensions) test 'creates a tls server to read and write data using IPv6' do omit "IPv6 unavailable here" unless ipv6_enabled? - received = "" + received = +"" responses = [] @d.server_create_tls(:s, @port, bind: "::1", tls_options: @tls_options) do |data, conn| received << data @@ -1440,7 +1442,7 @@ def assert_certificate(cert, expected_extensions) end test 'does not resolve name of client address in default' do - received = "" + received = +"" sources = [] @d.server_create_tls(:s, @port, tls_options: @tls_options) do |data, conn| received << data @@ -1460,7 +1462,7 @@ def assert_certificate(cert, expected_extensions) test 'does resolve name of client address if resolve_name is true' do hostname = Socket.getnameinfo([nil, nil, nil, "127.0.0.1"])[0] - received = "" + received = +"" sources = [] @d.server_create_tls(:s, @port, resolve_name: true, tls_options: @tls_options) do |data, conn| received << data @@ -1482,7 +1484,7 @@ def assert_certificate(cert, expected_extensions) end test 'raises error if plugin registers data callback for connection object from #server_create' do - received = "" + received = +"" errors = [] @d.server_create_tls(:s, @port, tls_options: @tls_options) do |data, conn| received << data @@ -1502,7 +1504,7 @@ def assert_certificate(cert, expected_extensions) end test 'can call write_complete callback if registered' do - buffer = "" + buffer = +"" lines = [] responses = [] response_completes = [] @@ -1533,7 +1535,7 @@ def assert_certificate(cert, expected_extensions) end test 'can call close callback if registered' do - buffer = "" + buffer = +"" lines = [] callback_results = [] @d.server_create_tls(:s, @port, tls_options: @tls_options) do |data, conn| @@ -1666,7 +1668,7 @@ def open_client(proto, addr, port) data(protocols) test 'does not resolve name of client address in default' do |(proto, kwargs)| - received = "" + received = +"" sources = [] @d.server_create_connection(:s, @port, proto: proto, **kwargs) do |conn| sources << conn.remote_host @@ -1688,7 +1690,7 @@ def open_client(proto, addr, port) test 'does resolve name of client address if resolve_name is true' do |(proto, kwargs)| hostname = Socket.getnameinfo([nil, nil, nil, "127.0.0.1"])[0] - received = "" + received = +"" sources = [] @d.server_create_connection(:s, @port, proto: proto, resolve_name: true, **kwargs) do |conn| sources << conn.remote_host @@ -1709,7 +1711,7 @@ def open_client(proto, addr, port) data(protocols) test 'creates a server to provide connection, which can read, write and close' do |(proto, kwargs)| lines = [] - buffer = "" + buffer = +"" @d.server_create_connection(:s, @port, proto: proto, **kwargs) do |conn| conn.data do |d| buffer << d @@ -1759,7 +1761,7 @@ def open_client(proto, addr, port) data(protocols) test 'creates a server to provide connection, which accepts callbacks for data, write_complete, and close' do |(proto, kwargs)| lines = [] - buffer = "" + buffer = +"" written = 0 closed = 0 @d.server_create_connection(:s, @port, proto: proto, **kwargs) do |conn| @@ -1794,7 +1796,7 @@ def open_client(proto, addr, port) data(protocols) test 'creates a server, and does not leak connections' do |(proto, kwargs)| - buffer = "" + buffer = +"" closed = 0 @d.server_create_connection(:s, @port, proto: proto, **kwargs) do |conn| conn.on(:close){|_c| closed += 1 } @@ -1825,7 +1827,7 @@ def open_client(proto, addr, port) assert_false connected - received = "" + received = +"" @d.server_create_connection(:s, @port, proto: proto, shared: false, **kwargs) do |conn| conn.on(:data) do |data| received << data