Skip to content

Commit eefd707

Browse files
committed
more ArJdbc cleanup - we can live safely without the Jdbc::Mutex object
1 parent 1d9addd commit eefd707

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/arjdbc/jdbc/connection.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ def initialize(config)
2020
connection # force the connection to load (@see RubyJDbcConnection.connection)
2121
set_native_database_types
2222
@stmts = {} # AR compatibility - statement cache not used
23-
rescue ::ActiveRecord::ActiveRecordError
24-
raise
2523
rescue Java::JavaSql::SQLException => e
2624
e = e.cause if defined?(NativeException) && e.is_a?(NativeException) # JRuby-1.6.8
2725
error = e.getMessage || e.getSQLState

lib/arjdbc/jdbc/discover.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module ArJdbc
2+
23
def self.discover_extensions
34
if defined?(::Gem) && ::Gem.respond_to?(:find_files)
45
files = ::Gem.find_files('arjdbc/discover')
@@ -8,11 +9,12 @@ def self.discover_extensions
89
File.exist?(discover) ? discover : nil
910
end.compact
1011
end
11-
files.each do |f|
12-
puts "Loading #{f}" if $DEBUG
13-
require f
12+
files.each do |file|
13+
puts "Loading AR-JDBC extension #{file}" if $DEBUG
14+
require file
1415
end
1516
end
1617

1718
discover_extensions
18-
end
19+
20+
end

lib/arjdbc/jdbc/driver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def initialize(name, properties = {})
1313
properties.each { |key, val| @properties[key] = val.to_s } if properties
1414
end
1515
end
16-
16+
1717
def driver_class
1818
@driver_class ||= begin
1919
driver_class_const = (@name[0...1].capitalize + @name[1..@name.length]).gsub(/\./, '_')
20-
Jdbc::Mutex.synchronized do
20+
Jdbc::DriverManager.java_class.synchronized do # avoid 2 threads here
2121
unless Jdbc.const_defined?(driver_class_const)
2222
driver_class_name = @name
2323
Jdbc.module_eval do

lib/arjdbc/jdbc/java.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
module ActiveRecord
55
module ConnectionAdapters
66
module Jdbc
7-
Mutex = java.lang.Object.new
87
DriverManager = java.sql.DriverManager
98
Types = java.sql.Types
109
end
11-
1210
java_import "arjdbc.jdbc.JdbcConnectionFactory"
1311
end
1412
end

0 commit comments

Comments
 (0)