Fix regression in reporting leaks introduced by 3c8c7fc7e9.

Motivation:

3c8c7fc7e9 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
1 changed files with 7 additions and 4 deletions

View File

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