adixitconfluent commented on code in PR #16431: URL: https://github.com/apache/kafka/pull/16431#discussion_r1650969451
########## core/src/test/java/kafka/server/share/SharePartitionManagerTest.java: ########## @@ -1221,6 +1224,36 @@ public void testReplicaManagerFetchShouldProceed() { any(), any(), any(ReplicaQuota.class), any()); } + @Test + public void testCloseSharePartitionManager() throws Exception { + SharePartitionManager sharePartitionManager = SharePartitionManagerBuilder.builder() + .withShareGroupPersister(mock(Persister.class)).build(); + + List<Integer> mockList = new ArrayList<>(); + sharePartitionManager.timer().add(createTimerTask(mockList)); + // Allowing first timer task to expire. The timer task will add an element to mockList. + TestUtils.waitForCondition( + () -> mockList.size() == 1, + DEFAULT_MAX_WAIT_TIMER_TASK_TIMEOUT_MS, + () -> "Timer task never got timed out."); + + sharePartitionManager.timer().add(createTimerTask(mockList)); + // Closing the sharePartitionManager closes timer object in sharePartitionManager. + sharePartitionManager.close(); + // Allowing second timer task to expire. It won't be able to add an element to mockList. + Thread.sleep(DEFAULT_MAX_WAIT_TIMER_TASK_TIMEOUT_MS); Review Comment: For that, we need to have a function in SharePartitionManager to set the timer object to this mockTimer object. We can mark it as `// Only for testing.` Do we want to take that route? -- 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