Skip to content

Commit

Permalink
Merge pull request #2301 from fluent/add-msgpack-unpack-error-to-unre…
Browse files Browse the repository at this point in the history
…coverable

output: Add MessagePack::UnpackError to unrecoverable case
  • Loading branch information
repeatedly authored Feb 21, 2019
2 parents 7b6d176 + 955f418 commit 640aefb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions test/plugin/test_output_as_buffered_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down

0 comments on commit 640aefb

Please sign in to comment.