tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r714027 - in /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool: PoolProperties.java PooledConnection.java
Date Fri, 14 Nov 2008 15:18:19 GMT
Author: fhanik
Date: Fri Nov 14 07:18:19 2008
New Revision: 714027

URL: http://svn.apache.org/viewvc?rev=714027&view=rev
Log:
use atomic counters

Modified:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=714027&r1=714026&r2=714027&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Fri
Nov 14 07:18:19 2008
@@ -19,12 +19,13 @@
 
 import java.lang.reflect.Method;
 import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
 /**
  * @author Filip Hanik
  *
  */
 public class PoolProperties {
-    protected static volatile int poolCounter = 1;
+    protected static AtomicInteger poolCounter = new AtomicInteger(0);
     protected Properties dbProperties = new Properties();
     protected String url = null;
     protected String driverClassName = null;
@@ -50,7 +51,7 @@
     protected int removeAbandonedTimeout = 60;
     protected boolean logAbandoned = false;
     protected int loginTimeout = 10000;
-    protected String name = "Tomcat Connection Pool["+(poolCounter++)+"]";
+    protected String name = "Tomcat Connection Pool["+(poolCounter.addAndGet(1))+"]";
     protected String password;
     protected String username;
     protected long validationInterval = 30000;

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=714027&r1=714026&r2=714027&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
Fri Nov 14 07:18:19 2008
@@ -38,7 +38,7 @@
     public static final int VALIDATE_INIT = 4;
 
     protected static Log log = LogFactory.getLog(PooledConnection.class);
-    protected static volatile int counter = 1;
+    protected static AtomicInteger counter = new AtomicInteger(01);
 
     protected PoolProperties poolProperties;
     protected java.sql.Connection connection;
@@ -53,7 +53,7 @@
     protected WeakReference<JdbcInterceptor> handler = null;
 
     public PooledConnection(PoolProperties prop, ConnectionPool parent) throws SQLException
{
-        instanceCount = counter++;
+        instanceCount = counter.addAndGet(1);
         poolProperties = prop;
         this.parent = parent;
     }



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


Mime
View raw message