From 4b1f11dd3a77b3846a83ffc5df122ebaa5f0022b Mon Sep 17 00:00:00 2001 From: leventov Date: Sat, 1 Oct 2016 22:37:47 +0300 Subject: [PATCH] Canonicalize file to where ChronicleMaps are persisted, to ensure CanonicalRandomAccessFiles work in the face of symbolic links provided to ChronicleMapBuilder (but unfortunately not hard links) --- .../java/net/openhft/chronicle/map/ChronicleMapBuilder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 749c316bc..1f7f8ee5e 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -1463,6 +1463,9 @@ public final class ChronicleMapBuilder implements replicated = replicationIdentifier != -1; persisted = true; + // It's important to canonicalize the file, because CanonicalRandomAccessFiles.acquire() + // relies on java.io.File equality, which doesn't account symlinks itself. + file = file.getCanonicalFile(); if (!file.exists()) { if (recover) throw new FileNotFoundException("file " + file + " should exist for recovery");