From 0f377921777b82f5d270187622327ece3d455353 Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Thu, 7 Jul 2016 09:32:48 +0100 Subject: [PATCH] Passing current tests for issue 46 --- lib/logstash/outputs/jdbc.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index 3dd11c5..472e5da 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -284,7 +284,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base end def retry_exception?(exception) - retrying = (exception.respond_to? 'getSQLState' and (RETRYABLE_SQLSTATE_CLASSES.include?(exception.getSQLState[0,2]) or @retry_sql_states.include?(exception.getSQLState))) + retrying = (exception.respond_to? 'getSQLState' and (RETRYABLE_SQLSTATE_CLASSES.include?(exception.getSQLState.to_s[0,2]) or @retry_sql_states.include?(exception.getSQLState))) log_jdbc_exception(exception, retrying) retrying @@ -292,10 +292,11 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base def log_jdbc_exception(exception, retrying) current_exception = exception - log_text = 'JDBC Exception. ' + (retrying ? 'Retrying' : 'No retry') + '.' + log_text = 'JDBC - Exception. ' + (retrying ? 'Retrying' : 'Not retrying') + '.' + log_method = (retrying ? 'warn' : 'error') loop do - @logger.error(log_text, :exception => current_exception, :backtrace => current_exception.backtrace) + @logger.send(log_method, log_text, :exception => current_exception, :backtrace => current_exception.backtrace) if current_exception.respond_to? 'getNextException' current_exception = current_exception.getNextException()