Do not delete uncompressed file on error.
@@ -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();
+ // 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));
- // 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
+ }
+
} catch (IOException e) {
// little we can do...
}
