chia7712 commented on code in PR #19888: URL: https://github.com/apache/kafka/pull/19888#discussion_r2126067970
########## metadata/src/main/java/org/apache/kafka/controller/metrics/QuorumControllerMetrics.java: ########## @@ -267,16 +267,15 @@ public long newActiveControllers() { } public void updateBrokerContactTime(int brokerId) { - AtomicLong contactTime = brokerContactTimesMs.computeIfAbsent(brokerId, k -> new AtomicLong()); - contactTime.set(time.milliseconds()); + brokerContactTimesMs.compute(brokerId, (id, timeMs) -> time.milliseconds()); Review Comment: The original implementation always update the value, right? If so, maybe using "put" is sufficient enough ########## metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerMetadataMetrics.java: ########## @@ -228,17 +228,17 @@ public void setBrokerRegistrationState(int brokerId, BrokerRegistration brokerRe } BrokerRegistrationState brokerState = getBrokerRegistrationState(brokerRegistration); if (brokerRegistrationStates.containsKey(brokerId)) { - brokerRegistrationStates.get(brokerId).set(brokerState.state()); + brokerRegistrationStates.computeIfPresent(brokerId, (id, state) -> brokerState.state()); Review Comment: It always update the value, right? If so, it could be replaced by put -- 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