From 65faea22fd54fd9875f2ca9d3088b4dc46d31cce Mon Sep 17 00:00:00 2001
From: keranbingaa <397294722@qq.com>
Date: Fri, 1 Dec 2023 10:05:16 +0800
Subject: [PATCH] [ISSUE #7534] Use high performance concurrent set to replace
 copyonwriteset (#7583)

* fix ISSUE #7534

* reformat code

* Remove the useless unit test

---------

Co-authored-by: RongtongJin <jinrongtong16@mails.ucas.ac.cn>
---
 .../rocketmq/namesrv/routeinfo/RouteInfoManagerNewTest.java   | 1 -
 .../org/apache/rocketmq/remoting/protocol/body/TopicList.java | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/namesrv/src/test/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManagerNewTest.java b/namesrv/src/test/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManagerNewTest.java
index 6002d1f5a..b52cf5074 100644
--- a/namesrv/src/test/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManagerNewTest.java
+++ b/namesrv/src/test/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManagerNewTest.java
@@ -130,7 +130,6 @@ public class RouteInfoManagerNewTest {
         topicList = TopicList.decode(content, TopicList.class);
         assertThat(topicList.getTopicList()).contains("TestTopic", "TestTopic1", "TestTopic2");
     }
-
     @Test
     public void registerBroker() {
         // Register master broker
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/TopicList.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/TopicList.java
index 30edfb5a9..0de0bae7e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/TopicList.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/TopicList.java
@@ -17,11 +17,11 @@
 package org.apache.rocketmq.remoting.protocol.body;
 
 import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
 
 public class TopicList extends RemotingSerializable {
-    private Set<String> topicList = new CopyOnWriteArraySet<>();
+    private Set<String> topicList = ConcurrentHashMap.newKeySet();
     private String brokerAddr;
 
     public Set<String> getTopicList() {
-- 
2.32.0.windows.2

