HADOOP-19049. Fix StatisticsDataReferenceCleaner classloader leak (#6488)

Contributed by Jia Fan
This commit is contained in:
Jia Fan 2024-02-03 22:48:52 +08:00 committed by GitHub
parent 141627778d
commit 4f0f5a546c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -4077,6 +4077,7 @@ private interface StatisticsAggregator<T> {
STATS_DATA_CLEANER.
setName(StatisticsDataReferenceCleaner.class.getName());
STATS_DATA_CLEANER.setDaemon(true);
STATS_DATA_CLEANER.setContextClassLoader(null);
STATS_DATA_CLEANER.start();
}

View File

@ -34,6 +34,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* This tests basic operations of {@link FileSystemStorageStatistics} class.
@ -102,6 +103,14 @@ public void testGetLong() {
}
}
@Test
public void testStatisticsDataReferenceCleanerClassLoader() {
Thread thread = Thread.getAllStackTraces().keySet().stream()
.filter(t -> t.getName().contains("StatisticsDataReferenceCleaner")).findFirst().get();
ClassLoader classLoader = thread.getContextClassLoader();
assertNull(classLoader);
}
/**
* Helper method to retrieve the specific FileSystem.Statistics value by name.
*