Clean serializers and ThreadLocal fields of VanillaChronicleMap on close()

This commit is contained in:
leventov
2016-12-27 15:50:24 +08:00
parent fa70e216bd
commit 842064dca5
3 changed files with 31 additions and 23 deletions
@@ -657,15 +657,20 @@ public abstract class VanillaChronicleHash<K,
@Override
public final void close() {
if (resources.releaseManually()) {
// Don't try to execute cleaner.clean() and ChronicleHashCloseOnExitHook.remove() from
// finally section of try block wrapping resources.releaseManually(), because
// Releases nothing after resources.releaseManually(), only removes the cleaner
// from the internal linked list of all cleaners.
cleaner.clean();
ChronicleHashCloseOnExitHook.remove(this);
cleanupOnClose();
}
}
protected void cleanupOnClose() {
// Releases nothing after resources.releaseManually(), only removes the cleaner
// from the internal linked list of all cleaners.
cleaner.clean();
ChronicleHashCloseOnExitHook.remove(this);
// Make GC life easier
keyReader = null;
keyDataAccess = null;
}
@Override
public boolean isOpen() {
return !resources.closed();