This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch driver-35 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 4499c8c4ec88240d5b2517ea0a6d0399add809e5 Author: stephen <[email protected]> AuthorDate: Wed Dec 11 08:38:34 2019 -0500 Tighten up sessioned Client close() operations Should fix NullPointerExceptions that have been popping up on Travis, though it's not clear that this is the root cause. --- .../java/org/apache/tinkerpop/gremlin/driver/Client.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 7b1589c..99342c0 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 @@ -770,7 +770,7 @@ public abstract class Client { // the connection pool may not have been initialized if requests weren't sent across it. in those cases // we just need to return a pre-completed future - if (connectionPool == null) { + if (null == connectionPool) { closing.set(CompletableFuture.completedFuture(null)); return closing.get(); } @@ -779,7 +779,7 @@ public abstract class Client { final RequestMessage closeMessage = buildMessage(RequestMessage.build(Tokens.OPS_CLOSE) .addArg(Tokens.ARGS_FORCE, forceClose)).create(); - final CompletableFuture<Void> sessionClose = CompletableFuture.supplyAsync(() -> { + closing.set(CompletableFuture.supplyAsync(() -> { try { // block this up until we get a response from the server or an exception. it might not be accurate // to wait for maxWaitForSessionClose because we wait that long for this future in calls to close() @@ -795,11 +795,9 @@ public abstract class Client { connectionPool.closeAsync(); } return null; - }, cluster.executor()); + }, cluster.executor())); - closing.set(sessionClose); - - return sessionClose; + return closing.get(); } @Override @@ -818,8 +816,9 @@ public abstract class Client { logger.warn(msg, ex); } finally { // a bit of an insurance policy for closing down the client side as we do already call this - // in closeAsync() - connectionPool.closeAsync().join(); + // in closeAsync(). it seems like a client can get created but maybe not initialized so when things + // get here the pull might be null. + if (connectionPool != null) connectionPool.closeAsync().join(); } } }
