aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/FileUtils.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/queue/InternalCeQueueImpl.java2
-rw-r--r--sonar-application/src/main/java/org/sonar/application/AppFileSystem.java13
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/FileUtils.java13
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java2
5 files changed, 22 insertions, 20 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java b/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java
index f25ac1f101a..b7b802a36e7 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java
@@ -98,26 +98,26 @@ public final class FileUtils {
public static void deleteDirectory(File directory) throws IOException {
requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
- Path path = directory.toPath();
- if (!Files.exists(path)) {
+ if (!directory.exists()) {
return;
}
+ Path path = directory.toPath();
if (Files.isSymbolicLink(path)) {
throw new IOException(format("Directory '%s' is a symbolic link", directory));
}
- if (Files.isRegularFile(path)) {
+ if (directory.isFile()) {
throw new IOException(format("Directory '%s' is a file", directory));
}
deleteDirectoryImpl(path);
- if (Files.exists(path)) {
+ if (directory.exists()) {
throw new IOException(format("Unable to delete directory '%s'", directory));
}
}
private static void cleanDirectoryImpl(Path path) throws IOException {
- if (!Files.isDirectory(path)) {
+ if (!path.toFile().isDirectory()) {
throw new IllegalArgumentException(format("'%s' is not a directory", path));
}
Files.walkFileTree(path, FOLLOW_LINKS, CleanDirectoryFileVisitor.VISIT_MAX_DEPTH, new CleanDirectoryFileVisitor(path));
@@ -145,7 +145,7 @@ public final class FileUtils {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- if (Files.isDirectory(file)) {
+ if (file.toFile().isDirectory()) {
deleteDirectoryImpl(file);
} else if (!symLink || !file.equals(path)) {
Files.delete(file);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/InternalCeQueueImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/InternalCeQueueImpl.java
index de096949334..bf19954b31e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/InternalCeQueueImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/InternalCeQueueImpl.java
@@ -127,7 +127,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
@CheckForNull
private static String getStackTraceForPersistence(Throwable error) {
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
- LineReturnEnforcedPrintStream printStream = new LineReturnEnforcedPrintStream(out);) {
+ LineReturnEnforcedPrintStream printStream = new LineReturnEnforcedPrintStream(out)) {
error.printStackTrace(printStream);
printStream.flush();
return out.toString();
diff --git a/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java b/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
index 01c19276757..da9f75affac 100644
--- a/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
+++ b/sonar-application/src/main/java/org/sonar/application/AppFileSystem.java
@@ -145,13 +145,14 @@ public class AppFileSystem implements FileSystem {
}
@Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- if (Files.isDirectory(file)) {
- deleteDirectory(file.toFile());
- } else if (file.getFileName().equals(SHAREDMEMORY_FILE)) {
+ public FileVisitResult visitFile(Path filePath, BasicFileAttributes attrs) throws IOException {
+ File file = filePath.toFile();
+ if (file.isDirectory()) {
+ deleteDirectory(file);
+ } else if (filePath.getFileName().equals(SHAREDMEMORY_FILE)) {
return CONTINUE;
- } else if (!symLink || !file.equals(path)) {
- Files.delete(file);
+ } else if (!symLink || !filePath.equals(path)) {
+ Files.delete(filePath);
}
return CONTINUE;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java b/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java
index df5e77dbe38..2b577505ea9 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java
@@ -69,7 +69,7 @@ public final class FileUtils {
requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
Path path = directory.toPath();
- if (!Files.exists(path)) {
+ if (!path.toFile().exists()) {
return;
}
@@ -112,23 +112,24 @@ public final class FileUtils {
}
private static void cleanDirectoryImpl(Path path) throws IOException {
- checkArgument(Files.isDirectory(path), "'%s' is not a directory", path);
+ checkArgument(path.toFile().isDirectory(), "'%s' is not a directory", path);
Files.walkFileTree(path, FOLLOW_LINKS, CleanDirectoryFileVisitor.VISIT_MAX_DEPTH, new CleanDirectoryFileVisitor(path));
}
private static void deleteDirectoryImpl(Path path) throws IOException {
requireNonNull(path, DIRECTORY_CAN_NOT_BE_NULL);
- if (!Files.exists(path)) {
+ File file = path.toFile();
+ if (!file.exists()) {
return;
}
checkIO(!Files.isSymbolicLink(path), "Directory '%s' is a symbolic link", path);
- checkIO(!Files.isRegularFile(path), "Directory '%s' is a file", path);
+ checkIO(!file.isFile(), "Directory '%s' is a file", path);
Files.walkFileTree(path, DeleteRecursivelyFileVisitor.INSTANCE);
- checkIO(!Files.exists(path), "Unable to delete directory '%s'", path);
+ checkIO(!file.exists(), "Unable to delete directory '%s'", path);
}
/**
@@ -149,7 +150,7 @@ public final class FileUtils {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- if (Files.isDirectory(file)) {
+ if (file.toFile().isDirectory()) {
deleteDirectoryImpl(file);
} else if (!symLink || !file.equals(path)) {
Files.delete(file);
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java
index 1cd271cb9d7..4402a1bac62 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java
@@ -147,7 +147,7 @@ public class PopulateUuidPathColumnOnProjects extends BaseDataChange {
}
// inputs: null (on Oracle), "", "1." or "1.2.3."
- private long[] parsePath(@Nullable String snapshotPath) {
+ private static long[] parsePath(@Nullable String snapshotPath) {
if (snapshotPath == null) {
return EMPTY_PATH;
}