2014-08-08 0:15 GMT+04:00  <fha...@apache.org>:
> Author: fhanik
> Date: Thu Aug  7 20:15:19 2014
> New Revision: 1616584
>
> URL: http://svn.apache.org/r1616584
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53853
> Dynamic class loading of driver, validator and interceptors can be done from 
> libraries on the context class loader. Behavior is partly backwards 
> compatible, always try the current loader first, but then attempts the 
> current thread's context class loader
>
> Added:
>     
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ClassLoaderUtil.java
>    (with props)
> Modified:
>     tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
>     
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
>     
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
>     
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
>
> Modified: tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
> URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml?rev=1616584&r1=1616583&r2=1616584&view=diff
> ==============================================================================
> --- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
> +++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Thu Aug  7 20:15:19 2014
> @@ -170,6 +170,22 @@
>        </attribute>
>      </attributes>
>    </subsection>
> +
> +  <subsection name="System Properties">
> +    <p>System properties are JVM wide, affect all pools created in the 
> JVM</p>
> +    <attributes>
> +      <attribute 
> name="org.apache.tomcat.jdbc.pool.onlyAttemptCurrentClassLoader" 
> required="false">
> +        <p>(boolean) Controls classloading of dynamic classes, such as
> +           jdbc drivers, interceptors and validators. If set to false, 
> default value,
> +           the pool will first attempt to load using the current loader and 
> if class loading fails
> +           attempt to load using the thread context loader.
> +           Set this value to try, if you wish to remain backwards compatible,

I have already fixed the typos here.

> +           Apache Tomcat 8.0.8 and earlier, and only attempt the current 
> loader.
> +           If not set then the default value is <code>false</code>.)
> +        </p>
> +      </attribute>
> +    </attributes>
> +  </subsection>
>

(...)


> Modified: 
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=1616584&r1=1616583&r2=1616584&view=diff
> ==============================================================================
> --- 
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
>  (original)
> +++ 
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
>  Thu Aug  7 20:15:19 2014
> @@ -767,7 +767,11 @@ public class PoolProperties implements P
>
>          try {
>              @SuppressWarnings("unchecked")
> -            Class<Validator> validatorClass = 
> (Class<Validator>)Class.forName(className);
> +            Class<Validator> validatorClass = 
> (Class<Validator>)ClassLoaderUtil.loadClass(
> +                className,
> +                PoolProperties.class.getClassLoader(),

OK.

> +                Thread.currentThread().getContextClassLoader()
> +            );
>              validator = validatorClass.newInstance();
>          } catch (ClassNotFoundException e) {
>              log.warn("The class "+className+" cannot be found.", e);
> @@ -957,12 +961,20 @@ public class PoolProperties implements P
>                      if (log.isDebugEnabled()) {
>                          log.debug("Loading interceptor 
> class:"+PoolConfiguration.PKG_PREFIX+getClassName());
>                      }
> -                    clazz = 
> Class.forName(PoolConfiguration.PKG_PREFIX+getClassName(), true, 
> this.getClass().getClassLoader());
> +                    clazz = ClassLoaderUtil.loadClass(
> +                        PoolConfiguration.PKG_PREFIX+getClassName(),
> +                        this.getClass().getClassLoader(),

It shall be "PoolProperties.class.getClassLoader()," as well here like
above. Otherwise the new code is not equivalent to the old one.

> +                        Thread.currentThread().getContextClassLoader()
> +                    );
>                  } else {
>                      if (log.isDebugEnabled()) {
>                          log.debug("Loading interceptor 
> class:"+getClassName());
>                      }
> -                    clazz = Class.forName(getClassName(), true, 
> this.getClass().getClassLoader());
> +                    clazz = ClassLoaderUtil.loadClass(
> +                        getClassName(),
> +                        this.getClass().getClassLoader(),
> +                        Thread.currentThread().getContextClassLoader()
> +                    );
>                  }
>              }
>              return (Class<? extends JdbcInterceptor>)clazz;
>

(...)

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to