You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/08/29 16:48:24 UTC

[3/6] tinkerpop git commit: Throw a proper exception when no available host

Throw a proper exception when no available host

When a SessionedClient is initialized and no host is available in the cluster,
A proper exception is thrown instead of an IndexOutOfBoundsException


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1b45e2ab
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1b45e2ab
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1b45e2ab

Branch: refs/heads/master
Commit: 1b45e2ab603bbe11f2777ce94452fe452209c268
Parents: 8912f79
Author: davidclement90 <da...@laposte.net>
Authored: Mon Aug 29 11:30:49 2016 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 29 12:24:52 2016 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java   | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1b45e2ab/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index a8b1710..4908d0e 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -521,6 +521,7 @@ public abstract class Client {
             final List<Host> hosts = cluster.allHosts()
                     .stream().filter(Host::isAvailable).collect(Collectors.toList());
             Collections.shuffle(hosts);
+            if (hosts.isEmpty()) throw new IllegalStateException("No available host in the cluster");
             final Host host = hosts.get(0);
             connectionPool = new ConnectionPool(host, this, Optional.of(1), Optional.of(1));
         }