You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cd...@apache.org on 2017/05/18 00:30:59 UTC

[4/5] hadoop git commit: HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination exists. Contributed by Lukas Majercak

HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination exists. Contributed by Lukas Majercak

(cherry picked from commit ef9e536a7137d209985d25a4769712c2db2c52bf)
(cherry picked from commit 4bb056544341726dd051353f1cc8430b801bf391)
(cherry picked from commit 475b50b44cebf5e5b4622e4092f4a447569b1b2b)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/954f9ce6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/954f9ce6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/954f9ce6

Branch: refs/heads/branch-2.8.1
Commit: 954f9ce657cb8843220457995ee20ae89273349b
Parents: 820496f
Author: Chris Douglas <cd...@apache.org>
Authored: Wed May 17 17:21:03 2017 -0700
Committer: Chris Douglas <cd...@apache.org>
Committed: Wed May 17 17:25:30 2017 -0700

----------------------------------------------------------------------
 .../main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c   | 2 +-
 .../test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/954f9ce6/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
index a7d4b55..242a456 100644
--- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
+++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
@@ -1204,7 +1204,7 @@ done:
   if (!src) goto done; // exception was thrown
   dst = (LPCWSTR) (*env)->GetStringChars(env, jdst, NULL);
   if (!dst) goto done; // exception was thrown
-  if (!MoveFile(src, dst)) {
+  if (!MoveFileEx(src, dst, MOVEFILE_REPLACE_EXISTING)) {
     throw_ioe(env, GetLastError());
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/954f9ce6/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
index e6f25dc..0f2c640 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
@@ -532,7 +532,7 @@ public class TestNativeIO {
         Assert.assertEquals(Errno.ENOENT, e.getErrno());
       }
     }
-    
+
     // Test renaming a file to itself.  It should succeed and do nothing.
     File sourceFile = new File(TEST_DIR, "source");
     Assert.assertTrue(sourceFile.createNewFile());
@@ -558,7 +558,9 @@ public class TestNativeIO {
       }
     }
 
-    FileUtils.deleteQuietly(TEST_DIR);
+    // Test renaming to an existing file
+    assertTrue(targetFile.exists());
+    NativeIO.renameTo(sourceFile, targetFile);
   }
 
   @Test(timeout=10000)


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org