HADOOP-12958. PhantomReference for filesystem statistics can trigger OOM. Contributed by Sangjin Lee

(cherry picked from commit 9a09200a1f)
This commit is contained in:
Jason Lowe 2016-03-25 22:56:49 +00:00
parent c58599acba
commit 5e823d839d
1 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@
import java.io.Closeable; import java.io.Closeable;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.PhantomReference; import java.lang.ref.WeakReference;
import java.lang.ref.ReferenceQueue; import java.lang.ref.ReferenceQueue;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -3119,7 +3119,7 @@ private interface StatisticsAggregator<T> {
/** /**
* Set of all thread-local data areas. Protected by the Statistics lock. * Set of all thread-local data areas. Protected by the Statistics lock.
* The references to the statistics data are kept using phantom references * The references to the statistics data are kept using weak references
* to the associated threads. Proper clean-up is performed by the cleaner * to the associated threads. Proper clean-up is performed by the cleaner
* thread when the threads are garbage collected. * thread when the threads are garbage collected.
*/ */
@ -3172,11 +3172,11 @@ public Void aggregate() {
} }
/** /**
* A phantom reference to a thread that also includes the data associated * A weak reference to a thread that also includes the data associated
* with that thread. On the thread being garbage collected, it is enqueued * with that thread. On the thread being garbage collected, it is enqueued
* to the reference queue for clean-up. * to the reference queue for clean-up.
*/ */
private class StatisticsDataReference extends PhantomReference<Thread> { private class StatisticsDataReference extends WeakReference<Thread> {
private final StatisticsData data; private final StatisticsData data;
public StatisticsDataReference(StatisticsData data, Thread thread) { public StatisticsDataReference(StatisticsData data, Thread thread) {