chia7712 commented on code in PR #15668: URL: https://github.com/apache/kafka/pull/15668#discussion_r1554964050
########## server-common/src/test/java/org/apache/kafka/server/util/timer/TimerTest.java: ########## @@ -76,6 +77,7 @@ public void setup() { @AfterEach public void teardown() throws Exception { timer.close(); + TestUtils.waitForCondition(() -> timer.isExecutorTerminated(), "timer excutor not terminated"); Review Comment: typo: excutor -> executor ########## server-common/src/test/java/org/apache/kafka/server/util/timer/SystemTimerReaperTest.java: ########## @@ -59,4 +60,16 @@ public void testReaper() throws Exception { timer.close(); } } + + @Test + public void testReaperClose() throws Exception { + Timer timer = Mockito.mock(Timer.class); + SystemTimerReaper timerReaper2 = new SystemTimerReaper("reaper", timer); + timerReaper2.close(); + Mockito.verify(timer, Mockito.times(1)).close(); + + SystemTimerReaper timerReaper = new SystemTimerReaper("reaper", new SystemTimer("timer")); + timerReaper.close(); + TestUtils.waitForCondition(() -> timerReaper.isShutdown(), "reaper not shutdown"); Review Comment: we can verity `timerReaper2` instead of `timerReaper` ########## server-common/src/main/java/org/apache/kafka/server/util/timer/SystemTimer.java: ########## @@ -110,4 +110,9 @@ public int size() { public void close() { taskExecutor.shutdown(); } + + // visible for testing + boolean isExecutorTerminated() { Review Comment: `isTerminated`. we don't need to expose name of inner variable -- 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