diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 0213772ab6..768fd5b5e1 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -4077,6 +4077,7 @@ private interface StatisticsAggregator { STATS_DATA_CLEANER. setName(StatisticsDataReferenceCleaner.class.getName()); STATS_DATA_CLEANER.setDaemon(true); + STATS_DATA_CLEANER.setContextClassLoader(null); STATS_DATA_CLEANER.start(); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java index e99f0f2348..5710049afb 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java @@ -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. *