aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-04-30 22:53:02 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-11 20:20:46 +0200
commit045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad (patch)
tree102fdf6e243de349571b9af3ab99fb0ed2644667 /sonar-home/src/main
parent75c553337901c4e09aa53f07f1659d8608ad5181 (diff)
downloadsonarqube-045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad.tar.gz
sonarqube-045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad.zip
SONAR-10591 Remove unused code in sonar-home
Diffstat (limited to 'sonar-home/src/main')
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/DirectoryLock.java14
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/FileCache.java20
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java9
3 files changed, 7 insertions, 36 deletions
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 e7b88a7f33d..db61bac9bcd 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
@@ -39,20 +39,6 @@ public class DirectoryLock {
this.lockFilePath = directory.resolve(LOCK_FILE_NAME).toAbsolutePath();
}
- public String getFileLockName() {
- return LOCK_FILE_NAME;
- }
-
- public void lock() {
- try {
- lockRandomAccessFile = new RandomAccessFile(lockFilePath.toFile(), "rw");
- lockChannel = lockRandomAccessFile.getChannel();
- lockFile = lockChannel.lock(0, 1024, false);
- } catch (IOException e) {
- throw new IllegalStateException("Failed to create lock in " + lockFilePath.toString(), e);
- }
- }
-
public boolean tryLock() {
try {
lockRandomAccessFile = new RandomAccessFile(lockFilePath.toFile(), "rw");
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java
index 89bb416e048..bc42ed0335c 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java
@@ -29,7 +29,6 @@ import java.nio.file.Path;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import java.util.zip.GZIPInputStream;
-import javax.annotation.CheckForNull;
/**
* This class is responsible for managing Sonar batch file cache. You can put file into cache and
@@ -62,24 +61,15 @@ public class FileCache {
return cacheDir;
}
- /**
- * Look for a file in the cache by its filename and md5 checksum. If the file is not
- * present then return null.
- */
- @CheckForNull
- public File get(String filename, String hash) {
- File cachedFile = new File(new File(cacheDir, hash), filename);
- if (cachedFile.exists()) {
- return cachedFile;
- }
- logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash));
- return null;
- }
-
public interface Downloader {
void download(String filename, File toFile) throws IOException;
}
+ /**
+ * Look for a file in the cache by its filename and md5 checksum. If the file is not
+ * present then try to download it. In case of error or if the file is not found
+ * an exception is thrown. {@code null} is never returned.
+ */
public File get(String filename, String hash, Downloader downloader) {
// Does not fail if another process tries to create the directory at the same time.
File hashDir = hashDir(hash);
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java
index 0734a28c9da..0bb78aada30 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java
@@ -31,13 +31,8 @@ public class FileCacheBuilder {
this.logger = logger;
}
- public FileCacheBuilder setUserHome(File d) {
- this.userHome = d;
- return this;
- }
-
- public FileCacheBuilder setUserHome(@Nullable String path) {
- this.userHome = (path == null) ? null : new File(path);
+ public FileCacheBuilder setUserHome(@Nullable File dir) {
+ this.userHome = dir;
return this;
}