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;
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);
}
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) {
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");
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) {