From d394ce70b73e26b799c8338489282691a02ecccf Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Thu, 22 Oct 2020 16:29:25 +0200 Subject: [PATCH] Introduce a system property that can disable file locking, Fix #236 --- src/main/java/net/openhft/chronicle/map/FileLockUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/FileLockUtil.java b/src/main/java/net/openhft/chronicle/map/FileLockUtil.java index 1c0e0125f..448f43332 100644 --- a/src/main/java/net/openhft/chronicle/map/FileLockUtil.java +++ b/src/main/java/net/openhft/chronicle/map/FileLockUtil.java @@ -19,7 +19,7 @@ public final class FileLockUtil { * Java file locks are maintained on a per JVM basis. So we need to manage them. */ private static final ConcurrentHashMap FILE_LOCKS = new ConcurrentHashMap<>(); - private static final boolean USE_LOCKING = !OS.isWindows(); + private static final boolean USE_LOCKING = !OS.isWindows() && !Boolean.getBoolean("chronicle.map.disable.locking"); private static final AtomicBoolean LOCK_WARNING_PRINTED = new AtomicBoolean(); private FileLockUtil() { } @@ -178,7 +178,7 @@ public final class FileLockUtil { private static void printWarningTheFirstTime() { if (LOCK_WARNING_PRINTED.compareAndSet(false, true)) { - Jvm.warn().on(FileLockUtil.class, "File locking is not supported on this platform (" + System.getProperty("os.name") + "). " + + Jvm.warn().on(FileLockUtil.class, "File locking is disabled or not supported on this platform (" + System.getProperty("os.name") + "). " + "Make sure you are not running ChronicleMapBuilder::*recover* methods when other processes or threads have the mapped file open!"); } }