HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination exists. Contributed by Lukas Majercak
(cherry picked from commitef9e536a71
) (cherry picked from commit4bb0565443
) (cherry picked from commit475b50b44c
)
This commit is contained in:
parent
0823fb72a9
commit
2b58fb8b03
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue