Skip to content

Move filewatch lib here, refactor and add new features. #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions lib/filewatch/read_mode/handlers/read_zip_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def handle_specifically(watched_file)
end
watched_file.listener.eof
rescue ZipException => e
logger.error("ReadZipFile: cannot decompress the gzip file at path: #{watched_file.path}")
logger.error("Cannot decompress the gzip file at path: #{watched_file.path}")
watched_file.listener.error
else
sincedb_collection.store_last_read(watched_file.sincedb_key, watched_file.last_stat_size)
Expand All @@ -36,21 +36,21 @@ def handle_specifically(watched_file)
watched_file.unwatch
ensure
# rescue each close individually so all close attempts are tried
close_java_closeable(buffered) unless buffered.nil?
close_java_closeable(decoder) unless decoder.nil?
close_java_closeable(gzip_stream) unless gzip_stream.nil?
close_java_closeable(file_stream) unless file_stream.nil?
close_and_ignore_ioexception(buffered) unless buffered.nil?
close_and_ignore_ioexception(decoder) unless decoder.nil?
close_and_ignore_ioexception(gzip_stream) unless gzip_stream.nil?
close_and_ignore_ioexception(file_stream) unless file_stream.nil?
end
sincedb_collection.unset_watched_file(watched_file)
end

private

def close_java_closeable(closeable)
def close_and_ignore_ioexception(closeable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

begin
closeable.close
rescue Exception # IOException can be thrown by any of the Java classes that implement the Closable interface.
# ignore this
logger.warn("Ignoring an IOException when closing an instance of #{closeable.class.name}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: add the exception detail too?

end
end
end
Expand Down