Skip to content

Commit

Permalink
Improve quality
Browse files Browse the repository at this point in the history
  • Loading branch information
dbmeneses committed Sep 30, 2015
1 parent f7eb2f5 commit 94beab4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand All @@ -46,11 +45,9 @@ public void save() {
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);
}
Expand All @@ -69,8 +66,7 @@ public Date getSyncStatus() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public PersistentCache provide(GlobalProperties props) {
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"), "/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ private void saveStatus() {

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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PersistentCache provide(GlobalProperties props, DefaultAnalysisMode mode,
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"), "/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ interface DataLoader<T> {

@Nonnull
private <T> WSLoaderResult<T> loadFromCache(String id, DataLoader<T> loader) throws NotAvailableException {
T result = null;
T result;

try {
result = loader.load(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static Path findHome() {
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) {
Expand Down

0 comments on commit 94beab4

Please sign in to comment.