lib/logstash/plugin_mixins/jdbc.rb in logstash-input-jdbc-4.2.3 vs lib/logstash/plugin_mixins/jdbc.rb in logstash-input-jdbc-4.2.4
- old
+ new
@@ -168,11 +168,11 @@
end
@database.fetch_size = @jdbc_fetch_size unless @jdbc_fetch_size.nil?
begin
@database.test_connection
rescue Sequel::DatabaseConnectionError => e
- @logger.warn("Failed test_connection.")
+ @logger.warn("Failed test_connection.", :exception => e)
close_jdbc_connection
#TODO return false and let the plugin raise a LogStash::ConfigurationError
raise e
end
@@ -203,10 +203,14 @@
end
end # def prepare_jdbc_connection
public
def close_jdbc_connection
- @database.disconnect if @database
+ begin
+ @database.disconnect if @database
+ rescue => e
+ @logger.warn("Failed to close connection", :exception => e)
+ end
@database = nil
end
public
def execute_statement(statement, parameters)