RFR 8060068 : Remove the static initializer block from DriverManager

Mandy Chung mandy.chung at oracle.com
Tue Dec 2 19:56:19 UTC 2014


On 12/1/14 8:52 AM, Lance Andersen wrote:
> Hi all,
>
> Looking for a review for this change to DriverManager to reduce the possibility on a deadlock on <clinit>. that I have been discussing with Mandy.
>
>
> The change removes the static initializer block as well as the synchronized keyword from registerDriver.
>
> The webrev can be found at http://cr.openjdk.java.net/%7Elancea/8060068/webrev.02/
>
initDriversIfNeeded() is called to ensure that the drivers are registered.
So it may be better to have a getter method to ensure driver classes are
loaded as well as return the registeredDrivers copy-on-write-arraylist.
i.e. you could rename initDriversIfNeeded to getRegisteredDrivers and
replace
   for(DriverInfo aDriver : registeredDrivers) {

with
   for(DriverInfo aDriver : getRegisteredDrivers())

line 564-567: this comment should belong to loadInitialDrivers right?
Nit line 567 - not align (one more space to the right needed)

Is driversSync object necessary?  Can you make loadInitialDrivers be
a synchronized method and move line 575-581 except 578 to the
loadInitialDrivers method (driversInitialized is volatile which is
good).

Mandy




More information about the core-libs-dev mailing list