From 09b022e9263f8bab28928986656839ec9477b77e Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sat, 9 Feb 2013 12:14:52 +0900 Subject: [PATCH] Use PhantomReference insteadof WeakReference for resource leak detection --- .../src/main/java/io/netty/util/ResourceLeakDetector.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/netty/util/ResourceLeakDetector.java b/common/src/main/java/io/netty/util/ResourceLeakDetector.java index 3af52383e8..1286157cb5 100644 --- a/common/src/main/java/io/netty/util/ResourceLeakDetector.java +++ b/common/src/main/java/io/netty/util/ResourceLeakDetector.java @@ -20,8 +20,8 @@ import io.netty.logging.InternalLogger; import io.netty.logging.InternalLoggerFactory; import io.netty.util.internal.SystemPropertyUtil; +import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicBoolean; @@ -131,6 +131,8 @@ public final class ResourceLeakDetector { break; } + ref.clear(); + if (!ref.close()) { continue; } @@ -141,7 +143,7 @@ public final class ResourceLeakDetector { } } - private final class DefaultResourceLeak extends WeakReference implements ResourceLeak { + private final class DefaultResourceLeak extends PhantomReference implements ResourceLeak { private final ResourceLeakException exception; private final AtomicBoolean freed;