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 2020/01/02 19:47:24 UTC
[tinkerpop] 20/22: Tighten up sessioned Client close() operations
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 dd0ae227988b0936b381d4cdefa218bfeaac0be5
Author: stephen <sp...@gmail.com>
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 5b04df5..ae48e4f 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
@@ -772,7 +772,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();
}
@@ -781,7 +781,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()
@@ -797,11 +797,9 @@ public abstract class Client {
connectionPool.closeAsync();
}
return null;
- }, cluster.executor());
+ }, cluster.executor()));
- closing.set(sessionClose);
-
- return sessionClose;
+ return closing.get();
}
@Override
@@ -820,8 +818,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();
}
}
}