mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Clean serializers and ThreadLocal fields of VanillaChronicleMap on close()
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -174,6 +174,15 @@ public class VanillaChronicleMap<K, V, R>
|
||||
cxt = new ThreadLocal<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanupOnClose() {
|
||||
super.cleanupOnClose();
|
||||
// Make GC life easier
|
||||
valueReader = null;
|
||||
valueDataAccess = null;
|
||||
cxt = null;
|
||||
}
|
||||
|
||||
public final V checkValue(Object value) {
|
||||
if (!valueClass.isInstance(value)) {
|
||||
throw new ClassCastException(toIdentityString() + ": Value must be a " +
|
||||
@@ -297,6 +306,9 @@ public class VanillaChronicleMap<K, V, R>
|
||||
}
|
||||
|
||||
final ChainingInterface q() {
|
||||
ThreadLocal<ContextHolder> cxt = this.cxt;
|
||||
if (cxt == null)
|
||||
throw new ChronicleHashClosedException(this);
|
||||
ContextHolder contextHolder = cxt.get();
|
||||
if (contextHolder == null) {
|
||||
ChainingInterface queryContext = newQueryContext();
|
||||
@@ -327,6 +339,9 @@ public class VanillaChronicleMap<K, V, R>
|
||||
}
|
||||
|
||||
final ChainingInterface i() {
|
||||
ThreadLocal<ContextHolder> cxt = this.cxt;
|
||||
if (cxt == null)
|
||||
throw new ChronicleHashClosedException(this);
|
||||
ContextHolder contextHolder = cxt.get();
|
||||
if (contextHolder == null) {
|
||||
ChainingInterface iterationContext = newIterationContext();
|
||||
|
||||
Reference in New Issue
Block a user