aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-11-09 11:03:34 +0100
committerHarald Musum <musum@yahooinc.com>2023-11-09 11:03:34 +0100
commit3e329570d51b6e286d38f2e6dbedd2e6bdefe3b3 (patch)
treef7b2952226f1afd3a93f86473fbd41d6e500fa7a /configserver
parentd11fd84c59e581e352376802fd54d23ac3b8d842 (diff)
Minor changes to compressed application stream handling
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStream.java24
2 files changed, 15 insertions, 11 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 e1629a6c2c3..fc60f1225a7 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
@@ -1100,7 +1100,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
try {
return in.decompress(tempDir);
} catch (IOException e) {
- throw new IllegalArgumentException("Unable to decompress stream", e);
+ throw new IllegalArgumentException("Unable to decompress application stream", e);
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStream.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStream.java
index 1b4ebb5cd61..9f5ae013447 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStream.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStream.java
@@ -61,22 +61,25 @@ public class CompressedApplicationInputStream implements AutoCloseable {
* Close this stream.
* @throws IOException if the stream could not be closed
*/
- public void close() throws IOException {
- reader.close();
- }
+ public void close() throws IOException { reader.close(); }
File decompress() throws IOException {
return decompress(uncheck(() -> java.nio.file.Files.createTempDirectory("decompress")).toFile());
}
public File decompress(File dir) throws IOException {
- decompressInto(dir.toPath());
- return dir;
+ try {
+ return decompressInto(dir.toPath());
+ } catch (IOException e) {
+ throw new IOException("Unable to decompress stream into " + dir.getAbsolutePath(), e);
+ }
}
- private void decompressInto(Path dir) throws IOException {
+ private File decompressInto(Path dir) throws IOException {
if (!Files.isDirectory(dir)) throw new IllegalArgumentException("Not a directory: " + dir.toAbsolutePath());
- log.log(Level.FINE, () -> "Application is in " + dir.toAbsolutePath());
+
+ String absolutePath = dir.toFile().getAbsolutePath();
+ log.log(Level.FINE, () -> "Decompress application into " + absolutePath);
int entries = 0;
Path tmpFile = null;
OutputStream tmpStream = null;
@@ -98,9 +101,10 @@ public class CompressedApplicationInputStream implements AutoCloseable {
if (tmpStream != null) tmpStream.close();
if (tmpFile != null) Files.deleteIfExists(tmpFile);
}
- if (entries == 0) {
- log.log(Level.WARNING, "Not able to decompress any entries to " + dir);
- }
+ if (entries == 0)
+ log.log(Level.WARNING, "Unable to decompress any entries into " + absolutePath);
+
+ return dir.toFile();
}
private static Path createTempFile(Path applicationDir) throws IOException {