hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject [5/5] hadoop git commit: HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination exists. Contributed by Lukas Majercak
Date Thu, 18 May 2017 00:31:00 GMT
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/2b58fb8b
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2b58fb8b
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2b58fb8b

Branch: refs/heads/branch-2.7
Commit: 2b58fb8b03ceeb930c2788052443f065ea007af4
Parents: 0823fb7
Author: Chris Douglas <cdouglas@apache.org>
Authored: Wed May 17 17:21:03 2017 -0700
Committer: Chris Douglas <cdouglas@apache.org>
Committed: Wed May 17 17:30:20 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2b58fb8b/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 2ddc0c4..515a93e 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -148,6 +148,9 @@ Release 2.7.4 - UNRELEASED
     HADOOP-12173. NetworkTopology::add calls toString always.
     (Inigo Goiri via cdouglas)
 
+    HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination
+    exists. (Lukas Majercak via cdouglas)
+
 Release 2.7.3 - 2016-08-25
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2b58fb8b/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 071d830..6f07fbe 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
@@ -1162,7 +1162,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/2b58fb8b/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 bf3ece7..513465f 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
@@ -543,7 +543,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());
@@ -569,7 +569,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


Mime
View raw message