hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umamah...@apache.org
Subject hadoop git commit: HDFS-9472. concat() API does not give proper exception messages on ./reserved relative path (Rakesh R via umamahesh)
Date Fri, 11 Dec 2015 08:02:08 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 5047ee56a -> 7dc558b6a


HDFS-9472. concat() API does not give proper exception messages on ./reserved relative path
(Rakesh R via umamahesh)

(cherry picked from commit e363417e7b7abdd5d149f303f729ecf3e95ef8f3)


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

Branch: refs/heads/branch-2
Commit: 7dc558b6a779819b62cec356f804edc4e30c0a35
Parents: 5047ee5
Author: Uma Mahesh <umamahesh@apache.org>
Authored: Thu Dec 10 23:55:29 2015 -0800
Committer: Uma Mahesh <umamahesh@apache.org>
Committed: Fri Dec 11 00:01:02 2015 -0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 .../hdfs/server/namenode/FSDirConcatOp.java     | 24 ++++++++++++++++----
 .../hdfs/server/namenode/TestHDFSConcat.java    | 19 ++++++++++++++++
 3 files changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7dc558b6/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 476feb5..3fd5231 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -868,6 +868,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-9527. The return type of FSNamesystem.getBlockCollection should be
     changed to INodeFile. (szetszwo)
 
+    HDFS-9472. concat() API does not give proper exception messages on ./reserved 
+    relative path (Rakesh R via umamahesh)
+
   OPTIMIZATIONS
 
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7dc558b6/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java
index 492994e..1885756 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java
@@ -49,14 +49,11 @@ class FSDirConcatOp {
 
   static HdfsFileStatus concat(FSDirectory fsd, String target, String[] srcs,
     boolean logRetryCache) throws IOException {
-    Preconditions.checkArgument(!target.isEmpty(), "Target file name is empty");
-    Preconditions.checkArgument(srcs != null && srcs.length > 0,
-      "No sources given");
+    validatePath(target, srcs);
     assert srcs != null;
     if (FSDirectory.LOG.isDebugEnabled()) {
       FSDirectory.LOG.debug("concat {} to {}", Arrays.toString(srcs), target);
     }
-
     final INodesInPath targetIIP = fsd.getINodesInPath4Write(target);
     // write permission for the target
     FSPermissionChecker pc = null;
@@ -86,6 +83,25 @@ class FSDirConcatOp {
     return fsd.getAuditFileInfo(targetIIP);
   }
 
+  private static void validatePath(String target, String[] srcs)
+      throws IOException {
+    Preconditions.checkArgument(!target.isEmpty(), "Target file name is empty");
+    Preconditions.checkArgument(srcs != null && srcs.length > 0,
+        "No sources given");
+    if (FSDirectory.isReservedRawName(target)
+        || FSDirectory.isReservedInodesName(target)) {
+      throw new IOException("Concat operation doesn't support "
+          + FSDirectory.DOT_RESERVED_STRING + " relative path : " + target);
+    }
+    for (String srcPath : srcs) {
+      if (FSDirectory.isReservedRawName(srcPath)
+          || FSDirectory.isReservedInodesName(srcPath)) {
+        throw new IOException("Concat operation doesn't support "
+            + FSDirectory.DOT_RESERVED_STRING + " relative path : " + srcPath);
+      }
+    }
+  }
+
   private static void verifyTargetFile(FSDirectory fsd, final String target,
       final INodesInPath targetIIP) throws IOException {
     // check the target

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7dc558b6/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java
index ded0031..6dc0782 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java
@@ -503,4 +503,23 @@ public class TestHDFSConcat {
     assertEquals(blockSize * 2, dfs.getFileStatus(trg).getLen());
     assertFalse(dfs.exists(src));
   }
+
+  @Test(timeout = 30000)
+  public void testConcatReservedRelativePaths() throws IOException {
+    String testPathDir = "/.reserved/raw/ezone";
+    Path dir = new Path(testPathDir);
+    dfs.mkdirs(dir);
+    Path trg = new Path(testPathDir, "trg");
+    Path src = new Path(testPathDir, "src");
+    DFSTestUtil.createFile(dfs, trg, blockSize, REPL_FACTOR, 1);
+    DFSTestUtil.createFile(dfs, src, blockSize, REPL_FACTOR, 1);
+    try {
+      dfs.concat(trg, new Path[] { src });
+      Assert.fail("Must throw Exception!");
+    } catch (IOException e) {
+      String errMsg = "Concat operation doesn't support "
+          + FSDirectory.DOT_RESERVED_STRING + " relative path : " + trg;
+      GenericTestUtils.assertExceptionContains(errMsg, e);
+    }
+  }
 }


Mime
View raw message