gaurav-narula commented on code in PR #15987:
URL: https://github.com/apache/kafka/pull/15987#discussion_r1605472276


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/runtime/MultiThreadedEventProcessorTest.java:
##########
@@ -475,9 +478,7 @@ public void testRecordThreadIdleRatio() throws Exception {
             doAnswer(invocation -> {
                 long threadIdleTime = idleTimeCaptured.getValue();
                 assertEquals(100, threadIdleTime);
-                synchronized (recordedIdleTimesMs) {
-                    recordedIdleTimesMs.add(threadIdleTime);
-                }
+                recordedIdleTimesMs.add(threadIdleTime);

Review Comment:
   Nit: might be useful to add a comment that this is safe because `numThreads` 
in line 470 is `1`.



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/runtime/MultiThreadedEventProcessorTest.java:
##########
@@ -61,8 +61,11 @@ public DelayEventAccumulator(Time time, long takeDelayMs) {
 
         @Override
         public CoordinatorEvent take() {
-            time.sleep(takeDelayMs);
-            return super.take();
+            CoordinatorEvent event = super.take();

Review Comment:
   IIUC, the fix suggests the flakyness is because `super.take()` returns 
`null` spuriously. I don't quite follow why that would happen though. Javadoc 
for `EventAccumulator::take` mentions it returns `null` only when the 
accumulator is closed. We also assert the value captured within doAnswer is 
`100`, `recordedIdleTimesMs.size() == 8` and 
`mockRuntimeMetrics.recordThreadIdleTime()` is invoked 8 times so where is the 
extra invocation coming from?



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