summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-12-10 16:38:02 +0100
committerGitHub <noreply@github.com>2021-12-10 16:38:02 +0100
commit050f5a07792f248e4530a197e1dd6b98d8f6706e (patch)
tree0b9f16c6e678b83c37e99886b395494b2589d166
parentd7109d19204eb636e6c1745a30f6f01810220c29 (diff)
parent1e961d3ed99b01cfa105e6cf2f1b925066fb5030 (diff)
Merge pull request #20455 from vespa-engine/hmusum/minor-changes
Make sure to always delete temp file/dir [run-systemtest]
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
index 89a77599909..a2c5fee1e51 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
@@ -131,9 +131,7 @@ public class FileReceiver {
throw new RuntimeException("Failed writing file: ", e);
} finally {
try {
- if (inprogressFile.exists()) {
- Files.delete(inprogressFile.toPath());
- }
+ Files.deleteIfExists(inprogressFile.toPath());
} catch (IOException e) {
log.log(Level.SEVERE, "Failed deleting " + inprogressFile.getAbsolutePath() + ": " + e.getMessage(), e);
}
@@ -191,13 +189,14 @@ public class FileReceiver {
} catch (FileAlreadyExistsException e) {
// Don't fail if it already exists (we might get the file from several config servers when retrying, servers are down etc.
// so it might be written already). Delete temp file/dir in that case, to avoid filling the disk.
- log.log(Level.FINE, () -> "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() +
- "', '" + destination.getAbsolutePath() + "' already exists");
- deleteFileOrDirectory(tempFile);
+ log.log(Level.FINE, () -> "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" +
+ destination.getAbsolutePath() + "', it already exists");
} catch (IOException e) {
String message = "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() + "'";
log.log(Level.SEVERE, message, e);
throw new RuntimeException(message, e);
+ } finally {
+ deleteFileOrDirectory(tempFile);
}
}