divijvaidya commented on PR #13078:
URL: https://github.com/apache/kafka/pull/13078#issuecomment-1377179705

   > Is there a reason we don't change the HashMap to a Concurrent*Map and just 
call `size()` on it? This way it becomes very clear that we expect some sort of 
a concurrent operation to happen on the map and we would like it to be ordered 
with respect to other operations and we do not have to rely on people knowing 
they need to interact with the `producers` map via additional functions?
   
   Using ConcurrentMaps would be ideal (we won't have to acquire a lock to 
perform read), but the `size()` operation of a concurrent map may produce stale 
data (case when it's being modified concurrently). The current approach 
guarantees that size is strongly consistent with the data stored in the map.


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to