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-9433. DFS getEZForPath API on a non-existent file should throw FileNotFoundException (Rakesh R via umamahesh)
Date Tue, 24 Nov 2015 01:55:19 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 8676a118a -> 411e2b2e7


HDFS-9433. DFS getEZForPath API on a non-existent file should throw FileNotFoundException
(Rakesh R via umamahesh)


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

Branch: refs/heads/trunk
Commit: 411e2b2e7cd63273a3819f99a3275821dfbcc9ce
Parents: 8676a11
Author: Uma Mahesh <umamahesh@apache.org>
Authored: Mon Nov 23 17:54:31 2015 -0800
Committer: Uma Mahesh <umamahesh@apache.org>
Committed: Mon Nov 23 17:54:31 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hdfs/DFSClient.java  |  4 +-
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../server/namenode/FSDirEncryptionZoneOp.java  |  4 ++
 .../apache/hadoop/hdfs/TestEncryptionZones.java | 50 +++++++++++++++++---
 4 files changed, 53 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/411e2b2e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
index ca0538e..2c42cbe 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
@@ -2671,8 +2671,8 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
     try (TraceScope ignored = newPathTraceScope("getEZForPath", src)) {
       return namenode.getEZForPath(src);
     } catch (RemoteException re) {
-      throw re.unwrapRemoteException(AccessControlException.class,
-          UnresolvedPathException.class);
+      throw re.unwrapRemoteException(FileNotFoundException.class,
+          AccessControlException.class, UnresolvedPathException.class);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/411e2b2e/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 47b9b08..e101913 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -2365,6 +2365,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-9423. Fix intermittent failure of TestEditLogTailer.
     (Masatake Iwasaki via waltersu4549)
 
+    HDFS-9433. DFS getEZForPath API on a non-existent file should throw FileNotFoundException
+    (Rakesh R via umamahesh)
+
 Release 2.7.3 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/411e2b2e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java
index 0f0b629..b663415 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs.server.namenode;
 
 import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.CRYPTO_XATTR_FILE_ENCRYPTION_INFO;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.util.AbstractMap;
@@ -172,6 +173,9 @@ final class FSDirEncryptionZoneOp {
     try {
       src = fsd.resolvePath(pc, srcArg, pathComponents);
       iip = fsd.getINodesInPath(src, true);
+      if (iip.getLastINode() == null) {
+        throw new FileNotFoundException("Path not found: " + iip.getPath());
+      }
       if (fsd.isPermissionEnabled()) {
         fsd.checkPathAccess(pc, iip, FsAction.READ);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/411e2b2e/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
index 64daeb3..3630f19 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
@@ -475,8 +476,13 @@ public class TestEncryptionZones {
           assertExceptionContains("Permission denied:", e);
         }
 
-        assertNull("expected null for nonexistent path",
-            userAdmin.getEncryptionZoneForPath(nonexistent));
+        try {
+          userAdmin.getEncryptionZoneForPath(nonexistent);
+          fail("FileNotFoundException should be thrown for a non-existent"
+              + " file path");
+        } catch (FileNotFoundException e) {
+          assertExceptionContains("Path not found: " + nonexistent, e);
+        }
 
         // Check operation with non-ez paths
         assertNull("expected null for non-ez path",
@@ -504,10 +510,20 @@ public class TestEncryptionZones {
         assertEquals("expected ez path", allPath.toString(),
             userAdmin.getEncryptionZoneForPath(
                 new Path(snapshottedAllPath)).getPath().toString());
-        assertNull("expected null for deleted file path",
-            userAdmin.getEncryptionZoneForPath(allPathFile));
-        assertNull("expected null for deleted directory path",
-            userAdmin.getEncryptionZoneForPath(allPath));
+        try {
+          userAdmin.getEncryptionZoneForPath(allPathFile);
+          fail("FileNotFoundException should be thrown for a non-existent"
+              + " file path");
+        } catch (FileNotFoundException e) {
+          assertExceptionContains("Path not found: " + allPathFile, e);
+        }
+        try {
+          userAdmin.getEncryptionZoneForPath(allPath);
+          fail("FileNotFoundException should be thrown for a non-existent"
+              + " file path");
+        } catch (FileNotFoundException e) {
+          assertExceptionContains("Path not found: " + allPath, e);
+        }
         return null;
       }
     });
@@ -1331,4 +1347,26 @@ public class TestEncryptionZones {
     assertEquals("Got unexpected ez path", "/somewhere/base/zone", dfsAdmin
         .getEncryptionZoneForPath(zoneDir).getPath().toString());
   }
+
+  @Test(timeout = 60000)
+  public void testGetEncryptionZoneOnANonExistentZoneFile() throws Exception {
+    final Path ez = new Path("/ez");
+    fs.mkdirs(ez);
+    dfsAdmin.createEncryptionZone(ez, TEST_KEY);
+    Path zoneFile = new Path(ez, "file");
+    try {
+      fs.getEZForPath(zoneFile);
+      fail("FileNotFoundException should be thrown for a non-existent"
+          + " file path");
+    } catch (FileNotFoundException e) {
+      assertExceptionContains("Path not found: " + zoneFile, e);
+    }
+    try {
+      dfsAdmin.getEncryptionZoneForPath(zoneFile);
+      fail("FileNotFoundException should be thrown for a non-existent"
+          + " file path");
+    } catch (FileNotFoundException e) {
+      assertExceptionContains("Path not found: " + zoneFile, e);
+    }
+  }
 }


Mime
View raw message