Skip to content

Commit

Permalink
remove org.apache.seata.core.rpc.netty.AbstractNettyRemotingClient#se…
Browse files Browse the repository at this point in the history
…ndAsyncResponse channelToRequestIds; and Check if the current log level is DEBUG or WARN.
  • Loading branch information
lyl2008dsg committed Mar 1, 2025
1 parent 4ba1621 commit 9d18625
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public void sendAsyncRequest(Channel channel, Object msg) {
public void sendAsyncResponse(String serverAddress, RpcMessage rpcMessage, Object msg) {
RpcMessage rpcMsg = buildResponseMessage(rpcMessage, msg, ProtocolConstants.MSGTYPE_RESPONSE);
Channel channel = clientChannelManager.acquireChannel(serverAddress);
channelToRequestIds.computeIfAbsent(channel, ch -> ConcurrentHashMap.newKeySet()).add(rpcMessage.getId());
super.sendAsync(channel, rpcMsg);
}

Expand Down Expand Up @@ -541,28 +540,40 @@ private void failFuturesForChannel(Channel channel, Throwable cause) {
private void removeRequestIdFromChannel(Channel channel, Integer requestId) {
if (channel == null) {
if (requestId != null) {
LOGGER.warn("Attempted to remove requestId {} from a null channel.", requestId);
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Attempted to remove requestId {} from a null channel.", requestId);
}
} else {
LOGGER.warn("Attempted to remove a null requestId from a null channel.");
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Attempted to remove a null requestId from a null channel.");
}
}
return;
}

if (requestId == null) {
LOGGER.warn("Attempted to remove a null requestId from channel {}.", channel);
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Attempted to remove a null requestId from channel {}.", channel);
}
return;
}

channelToRequestIds.computeIfPresent(channel, (ch, requestIds) -> {
boolean removed = requestIds.remove(requestId);
if (removed) {
LOGGER.debug("Removed requestId {} from channel {}.", requestId, ch);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Removed requestId {} from channel {}.", requestId, ch);
}
} else {
LOGGER.warn("Attempted to remove non-existing requestId {} from channel {}.", requestId, ch);
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Attempted to remove non-existing requestId {} from channel {}.", requestId, ch);
}
}

if (requestIds.isEmpty()) {
LOGGER.debug("No more requestIds associated with channel {}. Channel removed from mapping.", ch);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No more requestIds associated with channel {}. Channel removed from mapping.", ch);
}
return null;
}
return requestIds;
Expand Down

0 comments on commit 9d18625

Please sign in to comment.