HDFS-15557. Log the reason why a storage log file can't be deleted (#2274)
This commit is contained in:
parent
7fae4133e0
commit
ae089f2db7
|
@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -75,8 +76,12 @@ public class AtomicFileOutputStream extends FilterOutputStream {
|
|||
boolean renamed = tmpFile.renameTo(origFile);
|
||||
if (!renamed) {
|
||||
// On windows, renameTo does not replace.
|
||||
if (origFile.exists() && !origFile.delete()) {
|
||||
throw new IOException("Could not delete original file " + origFile);
|
||||
if (origFile.exists()) {
|
||||
try {
|
||||
Files.delete(origFile.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Could not delete original file " + origFile, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
NativeIO.renameTo(tmpFile, origFile);
|
||||
|
|
Loading…
Reference in New Issue