Address a concern raised in https://issues.apache.org/bugzilla/show_bug.cgi?id=49584
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 15 Sep 2010 11:42:55 +0000 (11:42 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 15 Sep 2010 11:42:55 +0000 (11:42 +0000)
Re-factor code to clarify con is never null when release is called.

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

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

index 9b9984b..81a8779 100644 (file)
@@ -605,12 +605,13 @@ public class ConnectionPool {
      * @return a PooledConnection that has been connected
      * @throws SQLException
      */
-    protected PooledConnection createConnection(long now, PooledConnection con) throws SQLException {
+    protected PooledConnection createConnection(long now,
+            PooledConnection notUsed) throws SQLException {
         //no connections where available we'll create one
+        PooledConnection con = create();
         boolean error = false;
         try {
             //connect and validate the connection
-            con = create();
             con.lock();
             con.connect();
             if (con.validate(PooledConnection.VALIDATE_INIT)) {
@@ -640,6 +641,7 @@ public class ConnectionPool {
                 throw ex;
             }
         } finally {
+            // con can never be null here
             if (error ) {
                 release(con);
             }