funky-eyes commented on code in PR #7095:
URL: https://github.com/apache/incubator-seata/pull/7095#discussion_r1972719437
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -501,4 +513,59 @@ public void close(ChannelHandlerContext ctx,
ChannelPromise future) throws Excep
}
}
+ /**
+ * Iterates over futures and marks all MessageFutures associated with the
specified Channel as failed.
+ *
+ * @param channel The Channel that has been disconnected or encountered an
exception.
+ * @param cause The reason for the failure.
+ */
+ private void failFuturesForChannel(Channel channel, Throwable cause) {
+ Set<Integer> requestIds = channelToRequestIds.remove(channel);
+ if (requestIds != null) {
+ for (Integer requestId : requestIds) {
+ MessageFuture future = futures.remove(requestId);
+ if (future != null) {
+ future.setResultMessage(cause);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the association between the specified Channel and requestId
from the channelToRequestIds mapping.
+ * If the Channel no longer has any associated requestId, the Channel will
be removed from the mapping.
+ *
+ * @param channel The Channel that has been disconnected or encountered
an exception.
+ * @param requestId The requestId to be removed.
+ */
+ private void removeRequestIdFromChannel(Channel channel, Integer
requestId) {
+ if (channel == null) {
+ if (requestId != null) {
+ LOGGER.warn("Attempted to remove requestId {} from a null
channel.", requestId);
+ } else {
+ 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);
+ return;
+ }
+
+ channelToRequestIds.computeIfPresent(channel, (ch, requestIds) -> {
Review Comment:
Assuming an inactive event occurs on channelread, is it possible for this
channel to remain permanently in channelToRequestIds?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]