Skip to content

Commit

Permalink
Swallow an exception on log processing
Browse files Browse the repository at this point in the history
This commit replaces @shuwada's [commit](3f1e750) that was created ~3 years ago

The plugin should't crash if a bad file was uploaded to S3

Fixes #136
  • Loading branch information
KIVagant authored and robbavey committed May 17, 2018
1 parent 7c2b3c4 commit 8d14c3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/logstash/inputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,14 @@ def update_metadata(metadata, event)

private
def read_file(filename, &block)
if gzip?(filename)
if gzip?(filename)
read_gzip_file(filename, block)
else
read_plain_file(filename, block)
end
rescue => e
# skip any broken file
@logger.error("Failed to read the file. Skip processing.", :filename => filename, :exception => e.message)
end

def read_plain_file(filename, block)
Expand All @@ -278,9 +281,6 @@ def read_gzip_file(filename, block)
while (line = buffered.readLine())
block.call(line)
end
rescue ZipException => e
@logger.error("Gzip codec: We cannot uncompress the gzip file", :filename => filename)
raise e
ensure
buffered.close unless buffered.nil?
decoder.close unless decoder.nil?
Expand Down

0 comments on commit 8d14c3e

Please sign in to comment.