Chronicle-Map icon indicating copy to clipboard operation
Chronicle-Map copied to clipboard

ChronicleMap flag skipCloseOnExitHook gets reset to false when loading map from and existing file

Open mrbald opened this issue 4 years ago • 4 comments

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.

mrbald avatar Mar 27 '20 15:03 mrbald

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.

jazdw avatar Jul 30 '21 22:07 jazdw

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);
            }

jazdw avatar Jul 30 '21 22:07 jazdw

@peter-lawrey are there any plans to fix this issue?

agusevas avatar Dec 05 '21 11:12 agusevas

It's on our backlog, if you would like it prioritised please contact [email protected]

RobAustin avatar Dec 06 '21 07:12 RobAustin