Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-1352 033a44d1a -> e66f2c983
Prevents connections from exceeding max size in the driver. A fix for TINKERPOP-1351 - see that issue for more details. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e66f2c98 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e66f2c98 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e66f2c98 Branch: refs/heads/TINKERPOP-1352 Commit: e66f2c98374e0ad53a38395091d72fb0e745f752 Parents: 033a44d Author: Stephen Mallette <[email protected]> Authored: Thu Jun 30 17:39:28 2016 -0400 Committer: Stephen Mallette <[email protected]> Committed: Thu Jun 30 17:39:28 2016 -0400 ---------------------------------------------------------------------- .../org/apache/tinkerpop/gremlin/driver/ConnectionPool.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e66f2c98/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java ---------------------------------------------------------------------- diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java index e51662e..96cb81b 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java @@ -120,8 +120,12 @@ final class ConnectionPool { if (connections.isEmpty()) { logger.debug("Tried to borrow connection but the pool was empty for {} - scheduling pool creation and waiting for connection", host); for (int i = 0; i < minPoolSize; i++) { - scheduledForCreation.incrementAndGet(); - newConnection(); + // If many connections are borrowed at the same time there needs to be a check to make sure no + // additional ones get scheduled for creation + if (scheduledForCreation.get() < minPoolSize) { + scheduledForCreation.incrementAndGet(); + newConnection(); + } } return waitForConnection(timeout, unit);
