This is an automated email from the ASF dual-hosted git repository.

jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a9e8e9b1a1a Add isClosed in ShardingSphereProxy. (#34035)
a9e8e9b1a1a is described below

commit a9e8e9b1a1a3f3b5874abd1d3c071cbaf2f0ec99
Author: Cong Hu <[email protected]>
AuthorDate: Fri Dec 13 13:37:26 2024 +0800

    Add isClosed in ShardingSphereProxy. (#34035)
---
 .../apache/shardingsphere/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 e9dd6229652..f39ac83e0be 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 @@ public final class ShardingSphereProxy {
     /**
      * 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;
     }
 }

Reply via email to