Review request 7190657 Modify getDriver() to call Thread.currentThread().getContextClassLoader();

David Holmes david.holmes at oracle.com
Sun Aug 12 11:19:32 UTC 2012


Lance,

On 11/08/2012 3:19 AM, Lance Andersen - Oracle wrote:
> Looking for a reviewer for the following change:
>
> -  add  a call to Thread.currentThread().getContextClassLoader() to DriverManager.getDriver()
> - Remove the synchronized block for the same call in getConnection()

What is the context for the change? What is it trying to achieve or avoid?

David

> Thank you.
>
> Best
> Lance
>
> localhost:sql lanceandersen$ hg diff DriverManager.java
> diff -r 629f357fc17b src/share/classes/java/sql/DriverManager.java
> --- a/src/share/classes/java/sql/DriverManager.java	Fri Aug 10 09:17:14 2012 -0400
> +++ b/src/share/classes/java/sql/DriverManager.java	Fri Aug 10 13:05:00 2012 -0400
> @@ -264,6 +264,10 @@
>           // be null.
>           ClassLoader callerCL = DriverManager.getCallerClassLoader();
>
> +        if(callerCL == null) {
> +            callerCL = Thread.currentThread().getContextClassLoader();
> +        }
> +
>           // Walk through the loaded registeredDrivers attempting to locate someone
>           // who understands the given URL.
>           for (DriverInfo aDriver : registeredDrivers) {
> @@ -563,11 +567,8 @@
>            * classloader, so that the JDBC driver class outside rt.jar
>            * can be loaded from here.
>            */
> -        synchronized(DriverManager.class) {
> -          // synchronize loading of the correct classloader.
> -          if(callerCL == null) {
> -              callerCL = Thread.currentThread().getContextClassLoader();
> -           }
> +        if(callerCL == null) {
> +            callerCL = Thread.currentThread().getContextClassLoader();
>           }
>
>           if(url == null) {
> localhost:sql lanceandersen$
>
> 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 mailing list