From ebe5596469b79dff5f80be7b7bdce4c37dae9e8f Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 6 Nov 2015 14:55:24 +0000 Subject: [PATCH] Update jdbc.rb Removes improper nil check which breaks event sprintf formatting examples --- lib/logstash/outputs/jdbc.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index 45ae2d9..0f1827a 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -121,10 +121,12 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base statement.setBoolean(idx + 1, true) when false statement.setBoolean(idx + 1, false) - when nil - statement.setString(idx + 1, nil) else - statement.setString(idx + 1, event.sprintf(i)) + if event[i].nil? and i =~ /%{/ + statement.setString(idx + 1, event.sprintf(i)) + else + statement.setString(idx + 1, nil) + end end end