suppress sonarqube nio performance warning

This commit is contained in:
Sebastian Sdorra
2019-12-05 15:20:47 +01:00
parent 88c3860092
commit 9525cba06b

View File

@@ -21,6 +21,7 @@ public final class CopyOnWrite {
replaceOriginalFile(targetFile, temporaryFile); replaceOriginalFile(targetFile, temporaryFile);
} }
@SuppressWarnings("squid:S3725") // performance of Files#isDirectory
private static void validateInput(Path targetFile) { private static void validateInput(Path targetFile) {
if (Files.isDirectory(targetFile)) { if (Files.isDirectory(targetFile)) {
throw new IllegalArgumentException("target file has to be a regular file, not a directory"); throw new IllegalArgumentException("target file has to be a regular file, not a directory");
@@ -36,7 +37,7 @@ public final class CopyOnWrite {
Files.createFile(temporaryFile); Files.createFile(temporaryFile);
} catch (IOException ex) { } catch (IOException ex) {
LOG.error("Error creating temporary file {} to replace file {}", temporaryFile, targetFile); LOG.error("Error creating temporary file {} to replace file {}", temporaryFile, targetFile);
throw new StoreException("could create temporary file", ex); throw new StoreException("could not create temporary file", ex);
} }
return temporaryFile; return temporaryFile;
} }
@@ -64,6 +65,7 @@ public final class CopyOnWrite {
deleteBackupFile(backupFile); deleteBackupFile(backupFile);
} }
@SuppressWarnings("squid:S3725") // performance of Files#exists
private static Path backupOriginalFile(Path targetFile) { private static Path backupOriginalFile(Path targetFile) {
Path directory = targetFile.getParent(); Path directory = targetFile.getParent();
if (Files.exists(targetFile)) { if (Files.exists(targetFile)) {