Skip to content

Commit

Permalink
HADOOP-19049. Fix StatisticsDataReferenceCleaner classloader leak (#6488
Browse files Browse the repository at this point in the history
)


Contributed by Jia Fan
  • Loading branch information
Hisoka-X committed Feb 3, 2024
1 parent 1416277 commit 4f0f5a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 4f0f5a5

Please sign in to comment.