Przeglądaj źródła

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

(cherry picked from commit ac1aa6c8197268ea83f44747199d560be9e299ae)
(cherry picked from commit c74e42b4a2293c8adb99b22929047a8d07242d06)
Akira Ajisaka 9 lat temu
rodzic
commit
68b1abe5cc

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -15,6 +15,9 @@ Release 2.6.3 - UNRELEASED
     HDFS-8615. Correct HTTP method in WebHDFS document.
     (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
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java

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

+ 13 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java

@@ -387,4 +387,17 @@ public class TestHDFSConcat {
     }
  
   }
+
+  @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));
+  }
 }