https://issues.apache.org/bugzilla/show_bug.cgi?id=50857
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 2 Mar 2011 21:15:07 +0000 (21:15 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 2 Mar 2011 21:15:07 +0000 (21:15 +0000)
Timeouts have to be trapped, and properly handled

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1076380 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

index 1583bf2..0faccfe 100644 (file)
@@ -140,11 +140,16 @@ public class ConnectionPool {
      * @throws SQLException
      */
     public Future<Connection> getConnectionAsync() throws SQLException {
-        PooledConnection pc = this.borrowConnection(0, null, null);
-        if (pc!=null) {
-            
-            return new ConnectionFuture(pc);
-        } 
+        try {
+            PooledConnection pc = borrowConnection(0, null, null);
+            if (pc!=null) {
+                return new ConnectionFuture(pc);
+            } 
+        }catch (SQLException x) {
+            if (x.getMessage().indexOf("NoWait")<0) {
+                throw x;
+            }
+        }
         //we can only retrieve a future if the underlying queue supports it.
         if (idle instanceof FairBlockingQueue<?>) {
             Future<PooledConnection> pcf = ((FairBlockingQueue<PooledConnection>)idle).pollAsync();