From c3298a3836c244c94fae9a9cbc1598ea3820d357 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 21 Sep 2017 08:56:49 -0700 Subject: [PATCH] Fix regression in reporting leaks introduced by 3c8c7fc7e9c27f87e64aad5bd1df6c58ed8ef36e. Motivation: 3c8c7fc7e9c27f87e64aad5bd1df6c58ed8ef36e introduced some changes to the ResourceLeakDetector that introduced a regression and so would always log that paranoid leak detection should be enabled even it was already. Modifications: Correctly not clear the recorded stacktraces when we process the reference queue so we can log these. Result: ResourceLeakDetector works again as expected. --- .../main/java/io/netty/util/ResourceLeakDetector.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/io/netty/util/ResourceLeakDetector.java b/common/src/main/java/io/netty/util/ResourceLeakDetector.java index 582a6507c9..16ffef6d05 100644 --- a/common/src/main/java/io/netty/util/ResourceLeakDetector.java +++ b/common/src/main/java/io/netty/util/ResourceLeakDetector.java @@ -266,7 +266,7 @@ public class ResourceLeakDetector { if (ref == null) { break; } - ref.close(); + ref.dispose(); } } @@ -284,9 +284,7 @@ public class ResourceLeakDetector { break; } - ref.clear(); - - if (!ref.close()) { + if (!ref.dispose()) { continue; } @@ -394,6 +392,11 @@ public class ResourceLeakDetector { } } + boolean dispose() { + clear(); + return allLeaks.remove(this, LeakEntry.INSTANCE); + } + @Override public boolean close() { // Use the ConcurrentMap remove method, which avoids allocating an iterator.