liuml07 commented on a change in pull request #2274:
URL: https://github.com/apache/hadoop/pull/2274#discussion_r483377105



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/util/AtomicFileOutputStream.java
##########
@@ -75,8 +76,13 @@ public void close() throws IOException {
         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

Review comment:
       Is it simpler
   ```
   throw new IOException("Could not delete original file " + origFile, e);
   ```
   
   Other than that, +1




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to