]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Try to acquire DB lock even if the lock file already exists 95/495/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Mon, 8 May 2017 10:14:49 +0000 (13:14 +0300)
committerJussi Koskela <jussi.koskela@semantum.fi>
Mon, 8 May 2017 10:14:49 +0000 (13:14 +0300)
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

bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java

index 12f0552e434e96638d6bdd7bcd22d440d3d9a674..db83f1395d005babeb09dbd500f5034d2326f503 100644 (file)
@@ -119,12 +119,8 @@ public class AcornDatabase implements Database {
     @Override
     public synchronized void start() throws ProCoreException {
         try {
     @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) {
 
             lock = lockFileChannel.tryLock();
             if (lock == null) {