mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Make OldDeletedCleanupThread daemon and don't wait for this thread to cease in ReplicatedChronicleMap.close(), because if the thread is already dead by the time cleanupThread.join() is called, this call hangs
This commit is contained in:
@@ -1811,19 +1811,6 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
OldDeletedEntriesCleanupThread cleanupThread = new OldDeletedEntriesCleanupThread(map);
|
||||
map.addCloseable(cleanupThread);
|
||||
cleanupThread.start();
|
||||
// WARNING this relies on the fact that ReplicatedChronicleMap closes closeables in the same
|
||||
// order as they are added, i. e. OldDeletedEntriesCleanupThread instance close()d before
|
||||
// the following closeable
|
||||
String mapIdentityString = map.toIdentityString();
|
||||
map.addCloseable(() -> {
|
||||
try {
|
||||
cleanupThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warn(mapIdentityString +
|
||||
": Interrupted while waiting for the cleanup thread to cease");
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,7 @@ class OldDeletedEntriesCleanupThread extends Thread
|
||||
|
||||
OldDeletedEntriesCleanupThread(ReplicatedChronicleMap<?, ?, ?> map) {
|
||||
super("Cleanup Thread for " + map.toIdentityString());
|
||||
setDaemon(true);
|
||||
this.mapRef = new WeakReference<>(map);
|
||||
cleanupTimeout = map.cleanupTimeout;
|
||||
cleanupTimeoutUnit = map.cleanupTimeoutUnit;
|
||||
|
||||
Reference in New Issue
Block a user