mattisonchao commented on code in PR #20647:
URL: https://github.com/apache/pulsar/pull/20647#discussion_r1241755375


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/MessageDeduplication.java:
##########
@@ -455,23 +455,17 @@ public synchronized void producerRemoved(String 
producerName) {
     public synchronized void purgeInactiveProducers() {
         long minimumActiveTimestamp = System.currentTimeMillis() - 
TimeUnit.MINUTES
                 
.toMillis(pulsar.getConfiguration().getBrokerDeduplicationProducerInactivityTimeoutMinutes());
-
-        Iterator<java.util.Map.Entry<String, Long>> mapIterator = 
inactiveProducers.entrySet().iterator();
-        boolean hasInactive = false;
-        while (mapIterator.hasNext()) {
-            java.util.Map.Entry<String, Long> entry = mapIterator.next();
-            String producerName = entry.getKey();
-            long lastActiveTimestamp = entry.getValue();
-
+        final AtomicBoolean hasInactive = new AtomicBoolean(false);
+        inactiveProducers.forEach((producerName, lastActiveTimestamp) -> {
             if (lastActiveTimestamp < minimumActiveTimestamp) {
                 log.info("[{}] Purging dedup information for producer {}", 
topic.getName(), producerName);
-                mapIterator.remove();
+                inactiveProducers.remove(producerName);

Review Comment:
   `ConcurrentModificationException`?



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