RongtongJin commented on code in PR #9554:
URL: https://github.com/apache/rocketmq/pull/9554#discussion_r2217265470


##########
broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java:
##########
@@ -386,11 +387,7 @@ public void scanNotActiveChannel() {
     }
 
     public HashSet<String> queryTopicConsumeByWho(final String topic) {
-        HashSet<String> groups = new HashSet<>();
-        if (this.topicGroupTable.get(topic) != null) {
-            groups.addAll(this.topicGroupTable.get(topic));
-        }
-        return groups;
+        return new 
HashSet<>(Optional.ofNullable(topicGroupTable.get(topic)).orElse(new 
HashSet<>()));

Review Comment:
   `new 
HashSet<>(Optional.ofNullable(topicGroupTable.get(topic)).orElseGet(HashSet::new));`
   lazy instantiation of the new HashSet would be better.



-- 
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]

Reply via email to