RFR 8060068 : Remove the static initializer block from DriverManager
lance.andersen at oracle.com
Tue Dec 2 22:25:43 UTC 2014
On Dec 2, 2014, at 5:10 PM, Mandy Chung <mandy.chung at oracle.com> wrote:
> Hi Bernd,
> On 12/2/14 1:49 PM, Bernd Eckenfels wrote:
>> just want to add two somewhat related observations:
>> we have a virtual JDBC driver which maps back to an real driver (or to
>> an Pool/Datasource which uses a real driver. This is to allow
>> JDBC URLs to work in different environments with no config. (Thats is
>> not the nices solution, but after we resolved the deadlocks it
>> works stable with the legacy code we need to support).
> Would you be able to try this patch and see if the deadlocks are reproducible? Lance has been trying to get customers to verify this patch as this code has been deadlock-prone. Your feedback would be very useful.
>> This does have two consequences which are related to this patch:
>> a) #getConnection() is used quite often, as it tunnels through to a
>> high performing pool (already mentioned as a good reason for DCL).
> Once the drivers are loaded and initialized (once), getConnection would
> not need any locking (it just checks the volatile boolean field).
correct as the registeredDrivers arraylist should be OK
> Do you see any potential performance issue with it?
>> b) there have been some deadlock conditions in the past in this area. I
>> can try to find the details later on, but it involved class
>> loading/registration and the driver's synchronized.
> This may be similar to the deadlock problem reported in this bug
> during the class initialization of DriverManager class and the
> driver classes (that also triggers DriverManager.<clinit>)
> This patch changes the loading/registration of the drivers to be
> lazy at the first time when getConnection, getDriver, getDrivers
> is called. No synchronized is done afterward.
This is how it used to be prior to adding the static initializer block.. The difference is we do not do this any longer in registerDriver as it was in JDBC 10 it is not needed.
The only time it is needed is when you are looking up a URL or return a driver. There was no need to do this in registerDriver ever.
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen at oracle.com
More information about the core-libs-dev