From 781ec410f24f40d4a5fd214614de569a168e297c Mon Sep 17 00:00:00 2001 From: Cong Hu Date: Fri, 13 Dec 2024 09:41:56 +0800 Subject: [PATCH] Add isClosed in ShardingSphereProxy. --- .../proxy/frontend/ShardingSphereProxy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java index e9dd622965251..f39ac83e0be0a 100644 --- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java +++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java @@ -54,6 +54,8 @@ public final class ShardingSphereProxy { private final EventLoopGroup workerGroup; + private boolean isClosed; + public ShardingSphereProxy() { bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1); workerGroup = getWorkerGroup(); @@ -157,10 +159,14 @@ private void initServerBootstrap(final ServerBootstrap bootstrap, final DomainSo /** * Close ShardingSphere-Proxy. */ - public void close() { + public synchronized void close() { + if (isClosed) { + return; + } bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); BackendExecutorContext.getInstance().getExecutorEngine().close(); ProxyContext.getInstance().getContextManager().close(); + isClosed = true; } }