tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r1073531 - in /tomcat/trunk/modules/jdbc-pool: java/org/apache/tomcat/jdbc/pool/ConnectionPool.java test/org/apache/tomcat/jdbc/test/Bug50805.java
Date Tue, 22 Feb 2011 22:42:44 GMT
Author: fhanik
Date: Tue Feb 22 22:42:44 2011
New Revision: 1073531

URL: http://svn.apache.org/viewvc?rev=1073531&view=rev
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=50805
Make sure we only call borrowConnection once per connection per checkout


Added:
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java   (with
props)
Modified:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=1073531&r1=1073530&r2=1073531&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java Tue
Feb 22 22:42:44 2011
@@ -142,6 +142,7 @@ public class ConnectionPool {
     public Future<Connection> getConnectionAsync() throws SQLException {
         PooledConnection pc = this.borrowConnection(0, null, null);
         if (pc!=null) {
+            
             return new ConnectionFuture(pc);
         } 
         //we can only retrieve a future if the underlying queue supports it.
@@ -1054,8 +1055,10 @@ public class ConnectionPool {
             this.pcFuture = pcf;
         }
         
-        public ConnectionFuture(PooledConnection pc) {
+        public ConnectionFuture(PooledConnection pc) throws SQLException {
             this.pc = pc;
+            result = ConnectionPool.this.setupConnection(pc);
+            configured.set(true);
         }
         /**
          * {@inheritDoc}

Added: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java?rev=1073531&view=auto
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java (added)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java Tue Feb
22 22:42:44 2011
@@ -0,0 +1,38 @@
+package org.apache.tomcat.jdbc.test;
+
+import java.sql.Connection;
+import java.util.concurrent.Future;
+
+public class Bug50805 extends DefaultTestCase {
+    public Bug50805(String name) {
+        super(name);
+    }
+    
+    public void test50805() throws Exception {
+        init();
+        this.datasource.setInitialSize(0);
+        this.datasource.setMaxActive(10);
+        this.datasource.setMinIdle(1);
+        
+        assertEquals("Current size should be 0.", 0, this.datasource.getSize());
+        
+        this.datasource.getConnection().close();
+        
+        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
+        assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
+        
+        Future<Connection> fc = this.datasource.getConnectionAsync();
+        
+        Connection con = fc.get();
+        
+        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        assertEquals("Idle size should be 0.", 0, this.datasource.getIdle());
+        assertEquals("Busy size should be 1.", 1, this.datasource.getActive());
+        
+        con.close();
+        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
+        assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
+    }
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/Bug50805.java
------------------------------------------------------------------------------
    svn:eol-style = native



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


Mime
View raw message