summaryrefslogtreecommitdiffstats
path: root/container-accesslogging
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-10-09 13:12:06 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-10-09 13:12:06 +0200
commitd5d36896f35234f903e0df6babcaefccfbba7454 (patch)
treeccc90dbe15a232fcc8476688ed72f6115de03990 /container-accesslogging
parent9aaab5f81a0a917bc9c9c93c005b808a11b9b1d2 (diff)
Do not delete uncompressed file on error.
Diffstat (limited to 'container-accesslogging')
-rw-r--r--container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java b/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java
index 057bc1ef8d6..8220f715b92 100644
--- a/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java
+++ b/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java
@@ -285,13 +285,17 @@ public class LogFileHandler extends StreamHandler {
StringBuilder cmd = new StringBuilder("gzip");
cmd.append(" < "). append(oldFileName).append(" > ").append(gzippedFileName);
Process p = r.exec(cmd.toString());
- p.waitFor();
- NativeIO nativeIO = new NativeIO();
- nativeIO.dropFileFromCache(oldFile); // Drop from cache in case somebody else has a reference to it preventing from dying quickly.
- oldFile.delete();
- nativeIO.dropFileFromCache(new File(gzippedFileName));
// Detonator pattern: Think of all the fun we can have if gzip isn't what we
// think it is, if it doesn't return, etc, etc
+
+ int retval = p.waitFor();
+ NativeIO nativeIO = new NativeIO();
+ nativeIO.dropFileFromCache(oldFile); // Drop from cache in case somebody else has a reference to it preventing from dying quickly.
+ if (retval == 0) {
+ oldFile.delete();
+ nativeIO.dropFileFromCache(new File(gzippedFileName));
+ }
+
} catch (IOException e) {
// little we can do...
}