fix some code smells reported by sonarqube

This commit is contained in:
Sebastian Sdorra
2018-11-30 08:19:47 +01:00
parent 53be8b112b
commit 84dd6bf60f
8 changed files with 21 additions and 55 deletions

View File

@@ -61,7 +61,8 @@ class PathDatabase {
private void ensureParentDirectoryExists() {
Path parent = storePath.getParent();
if (!Files.exists(parent)) {
// Files.exists is slow on java 8
if (!parent.toFile().exists()) {
try {
Files.createDirectories(parent);
} catch (IOException ex) {

View File

@@ -47,7 +47,6 @@ import sonia.scm.store.StoreConstants;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Clock;
import java.util.Collection;
@@ -98,7 +97,8 @@ public class XmlRepositoryDAO implements PathBasedRepositoryDAO {
private void read() {
Path storePath = createStorePath();
if (!Files.exists(storePath)) {
// Files.exists is slow on java 8
if (!storePath.toFile().exists()) {
return;
}

View File

@@ -13,6 +13,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -44,7 +45,7 @@ public final class XmlStreams {
}
public static XMLStreamReader createReader(Path path) throws IOException, XMLStreamException {
return createReader(Files.newBufferedReader(path, Charsets.UTF_8));
return createReader(Files.newBufferedReader(path, StandardCharsets.UTF_8));
}
public static XMLStreamReader createReader(File file) throws IOException, XMLStreamException {
@@ -57,7 +58,7 @@ public final class XmlStreams {
public static IndentXMLStreamWriter createWriter(Path path) throws IOException, XMLStreamException {
return createWriter(Files.newBufferedWriter(path, Charsets.UTF_8));
return createWriter(Files.newBufferedWriter(path, StandardCharsets.UTF_8));
}
public static IndentXMLStreamWriter createWriter(File file) throws IOException, XMLStreamException {