From a280429889a21f2f258041caa42264570017c31a Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Tue, 15 Mar 2016 14:58:03 +0100 Subject: SONAR-7124 Concurrent access to WS cache allowed --- .../src/main/java/org/sonar/home/cache/DirectoryLock.java | 14 +------------- .../test/java/org/sonar/home/cache/DirectoryLockTest.java | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'sonar-home') diff --git a/sonar-home/src/main/java/org/sonar/home/cache/DirectoryLock.java b/sonar-home/src/main/java/org/sonar/home/cache/DirectoryLock.java index 64dcb87a10a..81c1a2b5352 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/DirectoryLock.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/DirectoryLock.java @@ -20,16 +20,13 @@ package org.sonar.home.cache; import java.io.IOException; -import java.io.PrintWriter; import java.io.RandomAccessFile; -import java.io.StringWriter; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.nio.file.Files; import java.nio.file.Path; public class DirectoryLock { - static final String LOCK_FILE_NAME = ".sonar_lock"; + public static final String LOCK_FILE_NAME = ".sonar_lock"; private final Path lockFilePath; private final Logger logger; @@ -93,14 +90,5 @@ public class DirectoryLock { logger.error("Error closing file", e); } } - - try { - Files.delete(lockFilePath); - } catch (IOException e) { - // ignore, as an error happens if another process just started to acquire the same lock - StringWriter errors = new StringWriter(); - e.printStackTrace(new PrintWriter(errors)); - logger.debug("Couldn't delete lock file: " + lockFilePath.toString() + " " + errors.toString()); - } } } diff --git a/sonar-home/src/test/java/org/sonar/home/cache/DirectoryLockTest.java b/sonar-home/src/test/java/org/sonar/home/cache/DirectoryLockTest.java index b6deb72da3e..088b7b1f2f8 100644 --- a/sonar-home/src/test/java/org/sonar/home/cache/DirectoryLockTest.java +++ b/sonar-home/src/test/java/org/sonar/home/cache/DirectoryLockTest.java @@ -50,7 +50,6 @@ public class DirectoryLockTest { lock.lock(); assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists(); lock.unlock(); - assertThat(temp.getRoot().list()).isEmpty(); } @Test @@ -59,7 +58,6 @@ public class DirectoryLockTest { lock.tryLock(); assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists(); lock.unlock(); - assertThat(temp.getRoot().list()).isEmpty(); } @Test(expected = OverlappingFileLockException.class) -- cgit v1.2.3