Skip to content

Commit 4f0f5a5

Browse files
authored
HADOOP-19049. Fix StatisticsDataReferenceCleaner classloader leak (#6488)
Contributed by Jia Fan
1 parent 1416277 commit 4f0f5a5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,6 +4077,7 @@ private interface StatisticsAggregator<T> {
40774077
STATS_DATA_CLEANER.
40784078
setName(StatisticsDataReferenceCleaner.class.getName());
40794079
STATS_DATA_CLEANER.setDaemon(true);
4080+
STATS_DATA_CLEANER.setContextClassLoader(null);
40804081
STATS_DATA_CLEANER.start();
40814082
}
40824083

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import static org.junit.Assert.assertEquals;
3636
import static org.junit.Assert.assertNotNull;
37+
import static org.junit.Assert.assertNull;
3738

3839
/**
3940
* This tests basic operations of {@link FileSystemStorageStatistics} class.
@@ -102,6 +103,14 @@ public void testGetLong() {
102103
}
103104
}
104105

106+
@Test
107+
public void testStatisticsDataReferenceCleanerClassLoader() {
108+
Thread thread = Thread.getAllStackTraces().keySet().stream()
109+
.filter(t -> t.getName().contains("StatisticsDataReferenceCleaner")).findFirst().get();
110+
ClassLoader classLoader = thread.getContextClassLoader();
111+
assertNull(classLoader);
112+
}
113+
105114
/**
106115
* Helper method to retrieve the specific FileSystem.Statistics value by name.
107116
*

0 commit comments

Comments
 (0)