diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 42131f1bf..22d8882f6 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -1675,8 +1675,6 @@ public final class ChronicleMapBuilder implements replicated = replicationIdentifier != -1; persisted = true; - boolean created = false; - // It's important to canonicalize the file, because CanonicalRandomAccessFiles.acquire() // relies on java.io.File equality, which doesn't account symlinks itself. final File canonicalFile = file.getCanonicalFile(); @@ -1684,8 +1682,7 @@ public final class ChronicleMapBuilder implements if (recover) throw new FileNotFoundException("file " + canonicalFile + " should exist for recovery"); //noinspection ResultOfMethodCallIgnored - created = canonicalFile.createNewFile(); - + canonicalFile.createNewFile(); } final RandomAccessFile raf = CanonicalRandomAccessFiles.acquire(canonicalFile); final ChronicleHashResources resources = new PersistedChronicleHashResources(canonicalFile); @@ -1694,12 +1691,6 @@ public final class ChronicleMapBuilder implements if (raf.length() > 0) { result = openWithExistingFile(canonicalFile, raf, resources, recover, overrideBuilderConfig, corruptionListener); } else { - if (created) { - System.out.println("Sleeping before lock acquisition for 10 seconds"); - - Jvm.pause(10000); - } - // Atomic* allows lambda modification final AtomicReference> map = new AtomicReference<>(); final AtomicReference headerBuffer = new AtomicReference<>(); @@ -1726,7 +1717,7 @@ public final class ChronicleMapBuilder implements pauser.pause(10, TimeUnit.SECONDS); } catch (TimeoutException e) { - LOG.warn("Failed to write header: can't acquire exclusive file lock on empty file for 10 seconds", e); + LOG.warn("Failed to write header: can't acquire exclusive file lock on empty file [" + canonicalFile + "] for 10 seconds", e); Jvm.rethrow(e); } diff --git a/src/main/java/net/openhft/chronicle/map/LockTestMain.java b/src/main/java/net/openhft/chronicle/map/LockTestMain.java deleted file mode 100644 index 406b0f016..000000000 --- a/src/main/java/net/openhft/chronicle/map/LockTestMain.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.openhft.chronicle.map;/* - * Copyright 2016-2020 Chronicle Software - * - * https://chronicle.software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import net.openhft.chronicle.core.Jvm; - -import java.io.File; -import java.io.IOException; - -public class LockTestMain { - public static void main(String[] args) throws IOException { - File f = new File("mapfile"); - - ChronicleMap map = ChronicleMapBuilder - .of(Integer.class, Integer.class) - .entries(100) - .createPersistedTo(f); - - for (int i = 0; i < 10; i++) - map.put(i, i); - - for (int i = 0; i < 10; i++) { - if (!Integer.valueOf(i).equals(map.get(i))) - throw new IllegalStateException("FAIL"); - } - - System.out.println("Success"); - - System.out.println("Sleeping for 300 seconds"); - - Jvm.pause(300_000); - - } -}