muralibasani commented on code in PR #21964:
URL: https://github.com/apache/kafka/pull/21964#discussion_r4121703757
##########
storage/src/test/java/org/apache/kafka/storage/internals/log/RemoteIndexCacheTest.java:
##########
@@ -127,20 +127,25 @@ public void setup() throws IOException,
RemoteStorageException {
}
@AfterEach
- public void cleanup() throws InterruptedException {
+ public void cleanup() throws Exception {
reset(rsm);
- // the files created for the test will be deleted automatically on
thread exit since we use temp dir
- Utils.closeQuietly(cache, "RemoteIndexCache created for unit test");
- // best effort to delete the per-test resource. Even if we don't
delete, it is ok because the parent directory
- // will be deleted at the end of test.
+ // Close the cache directly instead of using closeQuietly to ensure
any exception during close
+ // (e.g. failure to shut down the cleaner scheduler) is properly
propagated rather than silently swallowed,
+ // which could leave the cleaner thread alive and cause the leaked
thread assertion below to fail.
try {
- Utils.delete(logDir);
- } catch (IOException ioe) {
- // ignore
+ cache.close();
+ } finally {
+ // best effort to delete the per-test resource. Even if we don't
delete, it is ok because the parent directory
+ // will be deleted at the end of test.
+ try {
+ Utils.delete(logDir);
+ } catch (IOException ioe) {
+ // ignore
+ }
+ // Verify no lingering threads. It is important to have this as
the very last statement in the @AfterEach
+ // because this may throw an exception and prevent cleanup after it
+
TestUtils.assertNoLeakedThreadsWithNameAndDaemonStatus(REMOTE_LOG_INDEX_CACHE_CLEANER_THREAD,
true);
Review Comment:
Yes, I have updated pr desc. .There is no resource leak in closeQuietly.
--
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]