From 955f41813e49e488fd77c8ca42c447288d20df19 Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Wed, 20 Feb 2019 22:25:07 +0900 Subject: [PATCH] output: Add MessagePack::UnpackError to unrecoverable case Signed-off-by: Masahiro Nakagawa --- lib/fluent/plugin/output.rb | 2 +- test/plugin/test_output_as_buffered_backup.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/output.rb b/lib/fluent/plugin/output.rb index c90f36e466..8ea11d66f1 100644 --- a/lib/fluent/plugin/output.rb +++ b/lib/fluent/plugin/output.rb @@ -1083,7 +1083,7 @@ def next_flush_time end end - UNRECOVERABLE_ERRORS = [Fluent::UnrecoverableError, TypeError, ArgumentError, NoMethodError] + UNRECOVERABLE_ERRORS = [Fluent::UnrecoverableError, TypeError, ArgumentError, NoMethodError, MessagePack::UnpackError] def try_flush chunk = @buffer.dequeue_chunk diff --git a/test/plugin/test_output_as_buffered_backup.rb b/test/plugin/test_output_as_buffered_backup.rb index 0d3e5517d5..69d22c9a45 100644 --- a/test/plugin/test_output_as_buffered_backup.rb +++ b/test/plugin/test_output_as_buffered_backup.rb @@ -177,7 +177,12 @@ def wait_flush(target_file) } end - test 'backup chunk without secondary' do + data('unrecoverable error' => Fluent::UnrecoverableError, + 'type error' => TypeError, + 'argument error' => ArgumentError, + 'no method error' => NoMethodError, + 'msgpack unpack error' => MessagePack::UnpackError) + test 'backup chunk without secondary' do |error_class| Fluent::SystemConfig.overwrite_system_config('root_dir' => TMP_DIR) do id = 'backup_test' hash = { @@ -188,7 +193,7 @@ def wait_flush(target_file) @i.configure(config_element('ROOT', '', {'@id' => id}, [config_element('buffer', 'tag', hash)])) @i.register(:write) { |chunk| chunk_id = chunk.unique_id; - raise Fluent::UnrecoverableError, "yay, your #write must fail" + raise error_class, "yay, your #write must fail" } flush_chunks