From af900e9416fffa8bbc2eb106c3457cfe5f0cc1b3 Mon Sep 17 00:00:00 2001 From: ChineseTony Date: Thu, 29 Feb 2024 10:47:25 +0800 Subject: [PATCH] [ISSUE #7868] Use entrySet to close channel --- .../rocketmq/remoting/netty/NettyRemotingClient.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java index 836910f8fa3..ede6005f541 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java @@ -362,8 +362,8 @@ public void shutdown() { try { this.timer.stop(); - for (String addr : this.channelTables.keySet()) { - this.channelTables.get(addr).close(); + for (Map.Entry channel : this.channelTables.entrySet()) { + channel.getValue().close(); } this.channelWrapperTables.clear(); @@ -943,8 +943,9 @@ protected void scanChannelTablesOfNameServer() { return; } - for (String addr : this.channelTables.keySet()) { - ChannelWrapper channelWrapper = this.channelTables.get(addr); + for (Map.Entry entry : this.channelTables.entrySet()) { + String addr = entry.getKey(); + ChannelWrapper channelWrapper = entry.getValue(); if (channelWrapper == null) { continue; }