From f4431aa71a15230c7eb9e7299ab47efad2b0c27e Mon Sep 17 00:00:00 2001 From: Anqi Date: Mon, 31 Oct 2022 14:46:50 +0800 Subject: [PATCH] update close() of connection pool to idempotent (#484) --- .../java/com/vesoft/nebula/client/graph/net/NebulaPool.java | 4 +++- .../nebula/client/graph/net/RoundRobinLoadBalancer.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/com/vesoft/nebula/client/graph/net/NebulaPool.java b/client/src/main/java/com/vesoft/nebula/client/graph/net/NebulaPool.java index 490b2081a..a1b3c8884 100644 --- a/client/src/main/java/com/vesoft/nebula/client/graph/net/NebulaPool.java +++ b/client/src/main/java/com/vesoft/nebula/client/graph/net/NebulaPool.java @@ -124,7 +124,9 @@ public boolean init(List addresses, NebulaPoolConfig config) * close the pool, all connections will be closed */ public void close() { - checkClosed(); + if (isClosed.get()) { + return; + } isClosed.set(true); this.loadBalancer.close(); this.objectPool.close(); diff --git a/client/src/main/java/com/vesoft/nebula/client/graph/net/RoundRobinLoadBalancer.java b/client/src/main/java/com/vesoft/nebula/client/graph/net/RoundRobinLoadBalancer.java index 1b3f3f3c2..e245141cf 100644 --- a/client/src/main/java/com/vesoft/nebula/client/graph/net/RoundRobinLoadBalancer.java +++ b/client/src/main/java/com/vesoft/nebula/client/graph/net/RoundRobinLoadBalancer.java @@ -48,7 +48,9 @@ public RoundRobinLoadBalancer(List addresses, int timeout, SSLParam } public void close() { - schedule.shutdownNow(); + if (!schedule.isShutdown()) { + schedule.shutdownNow(); + } } @Override