tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <devli...@hanik.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 22:33:29 GMT
On 1/4/2011 12:27 PM, sebb wrote:
> 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.

and if you read the code, you'll see that it doesn't matter. sometimes thread safety can be
ignored for the sake of performance and 
simplicity since there will never be a bug.

Filip


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


Mime
View raw message