poorbarcode commented on code in PR #23795:
URL: https://github.com/apache/pulsar/pull/23795#discussion_r1900499097


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumersClassic.java:
##########
@@ -560,8 +593,11 @@ public boolean hasSameKeySharedPolicy(KeySharedMeta ksm) {
                 && ksm.isAllowOutOfOrderDelivery() == 
this.allowOutOfOrderDelivery);
     }
 
-    public LinkedHashMap<Consumer, Position> getRecentlyJoinedConsumers() {
-        return recentlyJoinedConsumers;
+    public synchronized LinkedHashMap<Consumer, Position> 
getRecentlyJoinedConsumers() {
+        if (recentlyJoinedConsumers == null) {
+            return null;
+        }
+        return new LinkedHashMap<>(recentlyJoinedConsumers);

Review Comment:
   Because it will return the original collection, which may be modified by 
other threads



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