Skip to content

Commit

Permalink
[ISSUE #4855] Fix close tcp client failed (#4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alonexc committed Apr 22, 2024
1 parent 2e4fc1b commit 9ce5dd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
@Slf4j
public abstract class TcpClient implements Closeable {

protected static transient int CLIENTNO = 0;
protected static int CLIENTNO = 0;

static {
try {
Expand Down Expand Up @@ -123,12 +123,15 @@ public void initChannel(SocketChannel ch) {
@Override
public void close() {
try {

goodbye();

channel.disconnect().sync();
workers.shutdownGracefully();
workers.shutdownGracefully().sync();
if (heartTask != null) {
heartTask.cancel(false);
}
goodbye();

} catch (Exception e) {
Thread.currentThread().interrupt();
log.warn("close tcp client failed.|remote address={}", channel.remoteAddress(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public void registerBusiHandler(ReceiveMsgHook<CloudEvent> handler) throws Event
@Override
public void close() {
try {
goodbye();
super.close();
} catch (Exception ex) {
log.error("exception occurred when close", ex);
Expand Down

0 comments on commit 9ce5dd6

Please sign in to comment.