mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Move all ChronicleMap closing logic into independent ChronicleHashResources. Reference contexts from ThreadLocals via ContextHolders and clear references to contexts on closing ChronicleMap. Make some closing procedures more paranoid than they were. Cache ChronicleMap's identityString and always return the same String from toIdentityString(). Add Throwables.returnOrSuppress().
This commit is contained in:
@@ -1545,9 +1545,16 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
return result;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
resources.releaseManually();
|
||||
} catch (Exception e) {
|
||||
throwable.addSuppressed(e);
|
||||
try {
|
||||
resources.setChronicleHashIdentityString(
|
||||
"ChronicleHash{name=" + name + ", file=" + file + "}");
|
||||
} catch (Throwable t) {
|
||||
throwable.addSuppressed(t);
|
||||
} finally {
|
||||
resources.releaseManually();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throwable.addSuppressed(t);
|
||||
}
|
||||
throw Throwables.propagateNotWrapping(throwable, IOException.class);
|
||||
}
|
||||
@@ -1555,6 +1562,7 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
|
||||
private void prepareMapPublication(VanillaChronicleMap map) throws IOException {
|
||||
establishReplication(map);
|
||||
map.setResourcesName();
|
||||
map.registerCleaner();
|
||||
// Ensure safe publication of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
@@ -1729,9 +1737,16 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
return map;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
resources.releaseManually();
|
||||
} catch (Exception e) {
|
||||
throwable.addSuppressed(e);
|
||||
try {
|
||||
resources.setChronicleHashIdentityString(
|
||||
"ChronicleHash{name=" + name + ", file=null}");
|
||||
} catch (Throwable t) {
|
||||
throwable.addSuppressed(t);
|
||||
} finally {
|
||||
resources.releaseManually();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throwable.addSuppressed(t);
|
||||
}
|
||||
throw Throwables.propagate(throwable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user