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.
This commit is contained in:
Norman Maurer 2017-09-21 08:56:49 -07:00
parent 003c8cc7ab
commit c3298a3836

View File

@ -266,7 +266,7 @@ public class ResourceLeakDetector<T> {
if (ref == null) { if (ref == null) {
break; break;
} }
ref.close(); ref.dispose();
} }
} }
@ -284,9 +284,7 @@ public class ResourceLeakDetector<T> {
break; break;
} }
ref.clear(); if (!ref.dispose()) {
if (!ref.close()) {
continue; continue;
} }
@ -394,6 +392,11 @@ public class ResourceLeakDetector<T> {
} }
} }
boolean dispose() {
clear();
return allLeaks.remove(this, LeakEntry.INSTANCE);
}
@Override @Override
public boolean close() { public boolean close() {
// Use the ConcurrentMap remove method, which avoids allocating an iterator. // Use the ConcurrentMap remove method, which avoids allocating an iterator.