summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-05-24 11:03:05 +0200
committerHarald Musum <musum@oath.com>2018-05-24 11:03:05 +0200
commit51b215102eedcf41e36efaaf8e3de44fd5cbd0d6 (patch)
tree136791055e49f609c1894b9f67c4cd20f67d6be0 /configserver
parentd374817551addc54f349bb50b11250427a2ebec6 (diff)
Use try-finally in caller to make sure temp dir is always deleted
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 3a759a965a6..cef59809248 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -154,8 +154,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public PrepareResult deploy(CompressedApplicationInputStream in, PrepareParams prepareParams,
boolean ignoreLockFailure, boolean ignoreSessionStaleFailure, Instant now) {
File tempDir = Files.createTempDir();
- PrepareResult prepareResult = deploy(decompressApplication(in, tempDir), prepareParams, ignoreLockFailure, ignoreSessionStaleFailure, now);
- cleanupTempDirectory(tempDir);
+ PrepareResult prepareResult;
+ try {
+ prepareResult = deploy(decompressApplication(in, tempDir), prepareParams, ignoreLockFailure, ignoreSessionStaleFailure, now);
+ } finally {
+ cleanupTempDirectory(tempDir);
+ }
return prepareResult;
}
@@ -353,8 +357,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, InputStream in, String contentType) {
File tempDir = Files.createTempDir();
- long sessionId = createSession(applicationId, timeoutBudget, decompressApplication(in, contentType, tempDir));
- cleanupTempDirectory(tempDir);
+ long sessionId;
+ try {
+ sessionId = createSession(applicationId, timeoutBudget, decompressApplication(in, contentType, tempDir));
+ } finally {
+ cleanupTempDirectory(tempDir);
+ }
return sessionId;
}
@@ -451,7 +459,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
CompressedApplicationInputStream.createFromCompressedStream(in, contentType)) {
return decompressApplication(application, tempDir);
} catch (IOException e) {
- cleanupTempDirectory(tempDir);
throw new IllegalArgumentException("Unable to decompress data in body", e);
}
}
@@ -460,7 +467,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
try {
return in.decompress(tempDir);
} catch (IOException e) {
- cleanupTempDirectory(tempDir);
throw new IllegalArgumentException("Unable to decompress stream", e);
}
}