in impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/ClientChannelManager.java [169:209]
void closeChannel(final Channel channel) {
try {
if (this.lockChannelTables.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
boolean removeItemFromTable = true;
RemotingChannelFuture prevCW = null;
String addrRemote = null;
for (Map.Entry<String, RemotingChannelFuture> entry : channelTables.entrySet()) {
RemotingChannelFuture prev = entry.getValue();
if (prev.getChannel() != null) {
if (prev.getChannel() == channel) {
prevCW = prev;
addrRemote = entry.getKey();
break;
}
}
}
if (null == prevCW) {
LOG.info("eventCloseChannel: the channel[{}] has been removed from the channel table before", addrRemote);
removeItemFromTable = false;
}
if (removeItemFromTable) {
this.channelTables.remove(addrRemote);
LOG.info("closeChannel: the channel[{}] was removed from channel table", addrRemote);
//RemotingHelper.closeChannel(channel);
}
} catch (Exception e) {
LOG.error("closeChannel: close the channel exception", e);
} finally {
this.lockChannelTables.unlock();
}
} else {
LOG.warn("closeChannel: try to lock channel table, but timeout, {}ms", LOCK_TIMEOUT_MILLIS);
}
} catch (InterruptedException e) {
LOG.error("closeChannel exception", e);
}
}