AndrewJSchofield commented on code in PR #16513: URL: https://github.com/apache/kafka/pull/16513#discussion_r1663821656
########## server/src/main/java/org/apache/kafka/server/share/ShareSessionCache.java: ########## @@ -41,10 +41,10 @@ public class ShareSessionCache { private long numPartitions = 0; // A map of session key to ShareSession. - private Map<ShareSessionKey, ShareSession> sessions = new HashMap<>(); + private final Map<ShareSessionKey, ShareSession> sessions = new HashMap<>(); // Maps last used times to sessions. - private TreeMap<LastUsedKey, ShareSession> lastUsed = new TreeMap<>(); + private final TreeMap<LastUsedKey, ShareSession> lastUsed = new TreeMap<>(); // Visible for testing public synchronized TreeMap<LastUsedKey, ShareSession> lastUsed() { Review Comment: This seems a bit odd. This method exposes the TreeMap for testing, which breaks encapsulation and surely risks synchronization problems if used for anything other than testing. So, is there any point in the method being declared synchronized? Accessing the TreeMap in the caller is not going to be synchronized. -- 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