Chronicle-Map
Chronicle-Map copied to clipboard
ChronicleMap flag skipCloseOnExitHook gets reset to false when loading map from and existing file
The flag added in the PR 184 does not survive close/open. When opening an existing file it uses the default value from the map unmarshaller.
I found it quite confusing (and I don't think it has been mentioned clearly in the docs) that the map persists the settings it has been created with, silently ignoring whatever is passed on the builder. In my opinion the behavior should be biased towards "it's allowed to override behavior on re-open", because it would make binary releases with improved settings easier.
The skipCloseOnExitHook
field is neither read nor written by the marshalller. There is no way to turn off the exit hook for an existing file.
Work around:
try {
Class<?> closeOnExitHook = Class.forName("net.openhft.chronicle.hash.impl.ChronicleHashCloseOnExitHook");
Method method = closeOnExitHook.getDeclaredMethod("remove", VanillaChronicleHash.class);
method.setAccessible(true);
//noinspection JavaReflectionInvocation
method.invoke(null, this.database);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.warn("Failed to disable Chronicle Map exit hook", e);
}
@peter-lawrey are there any plans to fix this issue?
It's on our backlog, if you would like it prioritised please contact [email protected]