HDFS-9431. DistributedFileSystem#concat fails if the target path is relative. Contributed by Kazuho Fujii.

This commit is contained in:
Akira Ajisaka 2015-11-19 20:55:01 +09:00
parent 25e82b4eb9
commit ac1aa6c819
3 changed files with 17 additions and 1 deletions

View File

@ -581,7 +581,7 @@ public void concat(Path trg, Path [] psrcs) throws IOException {
for (int i=0; i<psrcs.length; i++) { for (int i=0; i<psrcs.length; i++) {
srcsStr[i] = getPathName(srcs[i]); srcsStr[i] = getPathName(srcs[i]);
} }
dfs.concat(getPathName(trg), srcsStr); dfs.concat(getPathName(absF), srcsStr);
} catch (UnresolvedLinkException e) { } catch (UnresolvedLinkException e) {
// Exception could be from trg or any src. // Exception could be from trg or any src.
// Fully resolve trg and srcs. Fail if any of them are a symlink. // Fully resolve trg and srcs. Fail if any of them are a symlink.

View File

@ -3456,6 +3456,9 @@ Release 2.6.3 - UNRELEASED
HDFS-8615. Correct HTTP method in WebHDFS document. HDFS-8615. Correct HTTP method in WebHDFS document.
(Brahma Reddy Battula via aajisaka) (Brahma Reddy Battula via aajisaka)
HDFS-9431. DistributedFileSystem#concat fails if the target path is
relative. (Kazuho Fujii via aajisaka)
Release 2.6.2 - 2015-10-28 Release 2.6.2 - 2015-10-28
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -490,4 +490,17 @@ public void testConcatWithQuotaIncrease() throws IOException {
Assert.assertEquals(blockSize * repl * (srcNum + 1), Assert.assertEquals(blockSize * repl * (srcNum + 1),
summary.getSpaceConsumed()); summary.getSpaceConsumed());
} }
@Test
public void testConcatRelativeTargetPath() throws IOException {
Path dir = new Path("/dir");
Path trg = new Path("trg");
Path src = new Path(dir, "src");
dfs.setWorkingDirectory(dir);
DFSTestUtil.createFile(dfs, trg, blockSize, REPL_FACTOR, 1);
DFSTestUtil.createFile(dfs, src, blockSize, REPL_FACTOR, 1);
dfs.concat(trg, new Path[]{src});
assertEquals(blockSize * 2, dfs.getFileStatus(trg).getLen());
assertFalse(dfs.exists(src));
}
} }