Refactor: to explicit Java (driver) class name loading #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a second attempt on fixing #83 as it seems to still manifest even with locking.
Few more observations on what's going on (with #83):
Sequel::JDBC.load_driver
ends up doing aneval
on the input (e.g.Java::oracle.jdbc.driver.OracleDriver
)the
eval
sometimes fails with aNameError
(having multiple drivers and executing threads is a factor)as hinted previously the problem seems to be specific to
'com.sybase.jdbc4.jdbc.SybDriver'
driver (+ having another driver such as'oracle.jdbc.driver.OracleDriver'
around as well)JRuby might have an underlying bug with
eval
and setting up the Java package structure for the driversat one point an ugly error came out - which indicates an underlying Java driver loading issue (although this might have been caused by the concurrent loading of different drivers - registering with
DriverManager
)the issue only happens when drivers are on the LS class-path (setting
jdbc_driver_library =>
did not reproduce!)with the changes in this PR the issue did no longer reproduce even if drivers were on the LS class-path
A bit simplified reproducer (does not need to run Logstash): https://gist.github.com/kares/850767d4be4d5323b068af9585e45d4a
p.s. Previous changes (from #84) could be reverted but I am keeping them in (they do not hurt - the lock just slows down multiple jdbc plugins starting), for now.
More investigation might be needed for an actual underlying cause (as well as the potential JRuby bug) but the changes presented here make sense regardless - skipping
eval
and doing a simplyClass.forName
is very similar to what an actual Java JDBC application would attempt to do (and should hopefully make debugging the problem easier).