tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1055137 - in /tomcat/trunk/modules/jdbc-pool: java/org/apache/tomcat/jdbc/pool/PooledConnection.java test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
Date Tue, 04 Jan 2011 19:27:57 GMT
On 4 January 2011 18:37,  <fhanik@apache.org> wrote:
> Author: fhanik
> Date: Tue Jan  4 18:37:44 2011
> New Revision: 1055137
>
> URL: http://svn.apache.org/viewvc?rev=1055137&view=rev
> Log:
> No need to instantiate a new driver instance each time, simply reuse the one we got
>
> Modified:
>    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
>    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
>
> Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java?rev=1055137&r1=1055136&r2=1055137&view=diff
> ==============================================================================
> --- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
(original)
> +++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
Tue Jan  4 18:37:44 2011
> @@ -74,7 +74,7 @@ public class PooledConnection {
>     /**
>      * If using a XAConnection underneath.
>      */
> -    private volatile javax.sql.XAConnection xaConnection;
> +    protected volatile javax.sql.XAConnection xaConnection;
>     /**
>      * When we track abandon traces, this string holds the thread dump
>      */
> @@ -117,6 +117,8 @@ public class PooledConnection {
>
>     private volatile boolean suspect = false;
>
> +    private java.sql.Driver driver = null;
> +
>     /**
>      * Constructor
>      * @param prop - pool properties
> @@ -229,10 +231,12 @@ public class PooledConnection {
>         }
>     }
>     protected void connectUsingDriver() throws SQLException {
> -        java.sql.Driver driver = null;
> +
>         try {
> -            driver = (java.sql.Driver) Class.forName(poolProperties.getDriverClassName(),
> -                                                     true,
PooledConnection.class.getClassLoader()).newInstance();
> +            if (driver==null)
> +                driver = (java.sql.Driver) Class.forName(poolProperties.getDriverClassName(),
> +                                                        
true, PooledConnection.class.getClassLoader()
> +                                                        
).newInstance();

This is not thread-safe.

>         } catch (java.lang.Exception cn) {
>             if (log.isDebugEnabled()) {
>                 log.debug("Unable to instantiate JDBC driver.", cn);
>
> Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java?rev=1055137&r1=1055136&r2=1055137&view=diff
> ==============================================================================
> --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
(original)
> +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
Tue Jan  4 18:37:44 2011
> @@ -34,7 +34,7 @@ import org.apache.tomcat.jdbc.test.drive
>
>  public class AlternateUsernameTest extends DefaultTestCase {
>
> -    private static final int iterations = (new Random(System.currentTimeMillis())).nextInt(1000000)+100000;
> +    private static final int iterations = 500000; //(new Random(System.currentTimeMillis())).nextInt(1000000)+100000;
>     public AlternateUsernameTest(String name) {
>         super(name);
>     }
> @@ -44,13 +44,15 @@ public class AlternateUsernameTest exten
>
>     private void testUsername(boolean allowUsernameChange) throws Exception {
>         long start = System.currentTimeMillis();
> +        int withoutuser =10;
> +        int withuser = withoutuser;
>         this.init();
> +        this.datasource.setMaxActive(withuser+withoutuser);
>         this.datasource.setDriverClassName(Driver.class.getName());
>         this.datasource.setUrl("jdbc:tomcat:test");
>         this.datasource.setAlternateUsernameAllowed(allowUsernameChange);
>         this.datasource.getConnection().close();
> -        int withoutuser =10;
> -        int withuser = withoutuser;
> +
>         TestRunner[] runners = new TestRunner[withuser+withoutuser];
>         for (int i=0; i<withuser; i++) {
>             TestRunner with = new TestRunner("foo","bar",datasource.getPoolProperties().getUsername(),datasource.getPoolProperties().getPassword());
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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


Mime
View raw message