diff options
Diffstat (limited to 'container-accesslogging/src')
-rw-r--r-- | container-accesslogging/src/main/java/com/yahoo/container/logging/LogFileHandler.java | 14 |
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... } |