[dna-commits] DNA SVN: r1496 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Dec 30 15:39:00 EST 2009


Author: bcarothers
Date: 2009-12-30 15:39:00 -0500 (Wed, 30 Dec 2009)
New Revision: 1496

Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryConnectionPool.java
Log:
DNA-606 RepositoryConnectionPool Returns Invalid Connections to the Available Pool

Applied patch that turns on connection validation and modifies the validateConnection(...) method to remove invalid connections from the in-use pool rather than returning them to the available pool.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryConnectionPool.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryConnectionPool.java	2009-12-30 20:18:42 UTC (rev 1495)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryConnectionPool.java	2009-12-30 20:39:00 UTC (rev 1496)
@@ -142,7 +142,7 @@
     /**
      * Flag specifying whether a connection should be validated before returning it from the {@link #getConnection()} method.
      */
-    private final AtomicBoolean validateConnectionBeforeUse = new AtomicBoolean(false);
+    private final AtomicBoolean validateConnectionBeforeUse = new AtomicBoolean(true);
 
     /**
      * The time in nanoseconds that ping should wait before timing out and failing.
@@ -648,7 +648,7 @@
                 if (runState == TERMINATED) return true;
                 if (nanos <= 0) return false;
                 nanos = termination.awaitNanos(nanos);
-                //this.logger.trace("---> Done waiting: run state = {0}; condition = {1}, {2} open",runState,termination,poolSize)
+                // this.logger.trace("---> Done waiting: run state = {0}; condition = {1}, {2} open",runState,termination,poolSize)
                 // ;
             }
         } finally {
@@ -821,8 +821,15 @@
             }
         } finally {
             if (invalidConnection != null) {
-                connection = null;
-                returnConnection(invalidConnection);
+                try {
+                    mainLock.lock();
+                    connection = null;
+                    this.poolSize--;
+                    this.inUseConnections.remove(connection);
+                    // returnConnection(invalidConnection);
+                } finally {
+                    mainLock.unlock();
+                }
             }
         }
         return connection;



More information about the dna-commits mailing list