From ca260ab8f66fabd96ec3af80a3143ae09907d3db Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Mon, 8 May 2017 13:14:49 +0300 Subject: [PATCH] Try to acquire DB lock even if the lock file already exists Lock file may already exist if the program crashed or was terminated forcefully. It is ok to try acquiring the lock on existing lock file. refs #7124 Change-Id: I1467dee3d889d18c68664f6df0b9fa9b13296351 --- .../src/org/simantics/acorn/internal/AcornDatabase.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java index 12f0552e4..db83f1395 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java @@ -119,12 +119,8 @@ public class AcornDatabase implements Database { @Override public synchronized void start() throws ProCoreException { try { - try { - lockFileChannel = lockFile.getFileSystem().provider().newFileChannel(lockFile, - EnumSet.of(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)); - } catch (FileAlreadyExistsException e) { - throw new ProCoreException("The database in folder " + folder.toAbsolutePath() + " is already in use!", e); - } + lockFileChannel = lockFile.getFileSystem().provider().newFileChannel(lockFile, + EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.WRITE)); lock = lockFileChannel.tryLock(); if (lock == null) { -- 2.47.1