Skip to content

Commit

Permalink
Add isClosed in ShardingSphereProxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhucong committed Dec 13, 2024
1 parent f23d908 commit 64dda27
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public final class ShardingSphereProxy {

private final EventLoopGroup workerGroup;

private boolean isClosed = true;

public ShardingSphereProxy() {
bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
workerGroup = getWorkerGroup();
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 64dda27

Please sign in to comment.