Skip to content

Commit

Permalink
Check if hosts are empty first before bothering to do a shuffle to ch…
Browse files Browse the repository at this point in the history
…oose one at random. CTR
  • Loading branch information
spmallette committed Aug 29, 2016
1 parent 1b45e2a commit 1a2d323
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.1.4 (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Improved the error provided by a client-side session if no hosts were available.
* Fixed a bug in `PropertiesTest` which assumed long id values.
* Fixed a bug in `StarGraph` around self-edges.
* Fixed a potential leak of a `ReferenceCounted` resource in Gremlin Server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ protected void initializeImplementation() {
// chooses an available host at random
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");
Collections.shuffle(hosts);
final Host host = hosts.get(0);
connectionPool = new ConnectionPool(host, this, Optional.of(1), Optional.of(1));
}
Expand Down

0 comments on commit 1a2d323

Please sign in to comment.