Skip to content

Commit 6c3cc60

Browse files
author
Guy Boertje
authored
Upd changelog + ensure drivers loaded once (omission from previous PR) (#348)
* DOH! left over change from previous PR * Add changelog entries
1 parent 1ddcd42 commit 6c3cc60

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 4.3.15
2+
- Use atomic booleam to load drivers once
3+
- Added CHANGELOG entries
4+
5+
## 4.3.14
6+
- Added support for driver loading in JDK 9+ [Issue 331](https://github.com/logstash-plugins/logstash-input-jdbc/issues/331)
7+
- Gem released without CHANGELOG additions
8+
19
## 4.3.13
210
- Changed documentation to generalize the PATH location [#297](https://github.com/logstash-plugins/logstash-input-jdbc/pull/297)
311

lib/logstash/plugin_mixins/jdbc/jdbc.rb

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,24 @@ def open_jdbc_connection
171171
require "sequel/adapters/jdbc"
172172

173173
Sequel.application_timezone = @plugin_timezone.to_sym
174-
175-
begin
176-
load_drivers
177-
Sequel::JDBC.load_driver(@jdbc_driver_class)
178-
rescue LogStash::Error => e
179-
# raised in load_drivers, e.cause should be the caught Java exceptions
180-
raise LogStash::PluginLoadingError, "#{e.message} and #{e.cause.message}"
181-
rescue Sequel::AdapterNotFound => e
182-
# fix this !!!
183-
message = if @jdbc_driver_library.nil?
184-
":jdbc_driver_library is not set, are you sure you included
185-
the proper driver client libraries in your classpath?"
186-
else
187-
"Are you sure you've included the correct jdbc driver in :jdbc_driver_library?"
174+
if @drivers_loaded.false?
175+
begin
176+
load_drivers
177+
Sequel::JDBC.load_driver(@jdbc_driver_class)
178+
rescue LogStash::Error => e
179+
# raised in load_drivers, e.cause should be the caught Java exceptions
180+
raise LogStash::PluginLoadingError, "#{e.message} and #{e.cause.message}"
181+
rescue Sequel::AdapterNotFound => e
182+
# fix this !!!
183+
message = if @jdbc_driver_library.nil?
184+
":jdbc_driver_library is not set, are you sure you included
185+
the proper driver client libraries in your classpath?"
186+
else
187+
"Are you sure you've included the correct jdbc driver in :jdbc_driver_library?"
188+
end
189+
raise LogStash::PluginLoadingError, "#{e}. #{message}"
188190
end
189-
raise LogStash::PluginLoadingError, "#{e}. #{message}"
191+
@drivers_loaded.make_true
190192
end
191193
@database = jdbc_connect()
192194
@database.extension(:pagination)
@@ -226,6 +228,7 @@ def open_jdbc_connection
226228
public
227229
def prepare_jdbc_connection
228230
@connection_lock = ReentrantLock.new
231+
@drivers_loaded = Concurrent::AtomicBoolean.new
229232
end
230233

231234
public

logstash-input-jdbc.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-input-jdbc'
3-
s.version = '4.3.14'
3+
s.version = '4.3.15'
44
s.licenses = ['Apache License (2.0)']
55
s.summary = "Creates events from JDBC data"
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

0 commit comments

Comments
 (0)