chia7712 commented on code in PR #16426:
URL: https://github.com/apache/kafka/pull/16426#discussion_r1666450437


##########
core/src/main/scala/kafka/server/KafkaRequestHandler.scala:
##########
@@ -255,24 +255,19 @@ class BrokerTopicMetrics(name: Option[String], 
remoteStorageEnabled: Boolean = f
   }
 
   case class MeterWrapper(metricType: String, eventType: String) {
+    private final val created = new AtomicBoolean(false)
     @volatile private var lazyMeter: Meter = _
-    private val meterLock = new Object

Review Comment:
   oh, sorry for my unclear comments. My point was both of them need sync to 
avoid "intermediate" state gets changed. For example:
   
   1. A_thread set created to false
   2. B_thread set created to true
   3. B_thread re-new object even though it is not removed
   4. A_thread remove it
   
   It results in corrupt output: the created is true but metrics object is 
nonexistent.



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