diff --git a/core/src/main/java/hudson/util/AtomicFileWriter.java b/core/src/main/java/hudson/util/AtomicFileWriter.java index 46c0a261edbadd501df130c2173eed122bf12ee0..f49d4b9ff54e0c64bc45a54b4870635fc0997cd3 100644 --- a/core/src/main/java/hudson/util/AtomicFileWriter.java +++ b/core/src/main/java/hudson/util/AtomicFileWriter.java @@ -23,6 +23,7 @@ */ package hudson.util; +import hudson.Util; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -107,9 +108,13 @@ public class AtomicFileWriter extends Writer { public void commit() throws IOException { close(); - if(destFile.exists() && !destFile.delete()) { - tmpFile.delete(); - throw new IOException("Unable to delete "+destFile); + if (destFile.exists()) { + try { + Util.deleteFile(destFile); + } catch (IOException x) { + tmpFile.delete(); + throw x; + } } tmpFile.renameTo(destFile); }