aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/DefaultProjectCacheStatus.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/GlobalPersistentCacheProvider.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/ProjectPersistentCacheProvider.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java2
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java2
6 files changed, 7 insertions, 12 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/DefaultProjectCacheStatus.java b/sonar-batch/src/main/java/org/sonar/batch/cache/DefaultProjectCacheStatus.java
index 3ecf425d11a..401a1455ac0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/DefaultProjectCacheStatus.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/DefaultProjectCacheStatus.java
@@ -26,7 +26,6 @@ import org.sonar.home.cache.PersistentCache;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.file.Files;
@@ -46,11 +45,9 @@ public class DefaultProjectCacheStatus implements ProjectCacheStatus {
Date now = new Date();
try {
- FileOutputStream fos = new FileOutputStream(getStatusFilePath().toFile());
- try (ObjectOutputStream objOutput = new ObjectOutputStream(fos)) {
+ try (ObjectOutputStream objOutput = new ObjectOutputStream(new FileOutputStream(getStatusFilePath().toFile()))) {
objOutput.writeObject(now);
}
-
} catch (IOException e) {
throw new IllegalStateException("Failed to write cache sync status", e);
}
@@ -69,8 +66,7 @@ public class DefaultProjectCacheStatus implements ProjectCacheStatus {
if (!Files.isRegularFile(p)) {
return null;
}
- InputStream is = new FileInputStream(p.toFile());
- try (ObjectInputStream objInput = new ObjectInputStream(is)) {
+ try (ObjectInputStream objInput = new ObjectInputStream(new FileInputStream(p.toFile()))) {
return (Date) objInput.readObject();
}
} catch (IOException | ClassNotFoundException e) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/GlobalPersistentCacheProvider.java b/sonar-batch/src/main/java/org/sonar/batch/cache/GlobalPersistentCacheProvider.java
index 26d8a215957..391d5248062 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/GlobalPersistentCacheProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/GlobalPersistentCacheProvider.java
@@ -49,7 +49,7 @@ public class GlobalPersistentCacheProvider extends ProviderAdapter {
return cache;
}
- private String getServerUrl(GlobalProperties props) {
+ private static String getServerUrl(GlobalProperties props) {
return StringUtils.removeEnd(StringUtils.defaultIfBlank(props.property("sonar.host.url"), "http://localhost:9000"), "/");
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
index 4445eaae606..4ba15ab16a6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
@@ -89,10 +89,9 @@ public class ProjectCacheSynchronizer {
private void loadData(String projectKey) {
Profiler profiler = Profiler.create(Loggers.get(ProjectCacheSynchronizer.class));
- ProjectRepositories projectRepo = null;
profiler.startInfo("Load project settings");
- projectRepo = projectRepositoriesLoader.load(projectKey, true, null);
+ ProjectRepositories projectRepo = projectRepositoriesLoader.load(projectKey, true, null);
if (!projectRepo.exists()) {
LOG.debug("Project doesn't exist in the server");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectPersistentCacheProvider.java b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectPersistentCacheProvider.java
index 49684faff18..601ca335f7c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectPersistentCacheProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectPersistentCacheProvider.java
@@ -61,7 +61,7 @@ public class ProjectPersistentCacheProvider extends ProviderAdapter {
return cache;
}
- private String getServerUrl(GlobalProperties props) {
+ private static String getServerUrl(GlobalProperties props) {
return StringUtils.removeEnd(StringUtils.defaultIfBlank(props.property("sonar.host.url"), "http://localhost:9000"), "/");
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java b/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
index 6535e2c6445..a430a3ce93e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
@@ -149,7 +149,7 @@ public class WSLoader {
@Nonnull
private <T> WSLoaderResult<T> loadFromCache(String id, DataLoader<T> loader) throws NotAvailableException {
- T result = null;
+ T result;
try {
result = loader.load(id);
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
index 7be8fae66e8..51a05b7bf9c 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java
@@ -99,7 +99,7 @@ public class PersistentCacheBuilder {
return Paths.get(home, ".sonar");
}
- private String sanitizeFilename(String name) {
+ private static String sanitizeFilename(String name) {
try {
return URLEncoder.encode(name, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {