hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r642336 - in /hadoop/core/branches/branch-0.16: CHANGES.txt src/java/org/apache/hadoop/dfs/FSDirectory.java src/test/org/apache/hadoop/security/TestPermission.java
Date Fri, 28 Mar 2008 19:05:01 GMT
Author: shv
Date: Fri Mar 28 12:04:59 2008
New Revision: 642336

URL: http://svn.apache.org/viewvc?rev=642336&view=rev
Log:
HADOOP-3108. Fix NPE in setPermission and setOwner. Contributed by Konstantin Shvachko.

Modified:
    hadoop/core/branches/branch-0.16/CHANGES.txt
    hadoop/core/branches/branch-0.16/src/java/org/apache/hadoop/dfs/FSDirectory.java
    hadoop/core/branches/branch-0.16/src/test/org/apache/hadoop/security/TestPermission.java

Modified: hadoop/core/branches/branch-0.16/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.16/CHANGES.txt?rev=642336&r1=642335&r2=642336&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.16/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.16/CHANGES.txt Fri Mar 28 12:04:59 2008
@@ -849,6 +849,8 @@
     HADOOP-2768. Fix performance regression caused by HADOOP-1707.
     (dhruba borthakur via nigel)
 
+    HADOOP-3108. Fix NPE in setPermission and setOwner. (shv)
+
 Release 0.15.3 - 2008-01-18
 
   BUG FIXES

Modified: hadoop/core/branches/branch-0.16/src/java/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.16/src/java/org/apache/hadoop/dfs/FSDirectory.java?rev=642336&r1=642335&r2=642336&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.16/src/java/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ hadoop/core/branches/branch-0.16/src/java/org/apache/hadoop/dfs/FSDirectory.java Fri Mar
28 12:04:59 2008
@@ -406,9 +406,12 @@
     fsImage.getEditLog().logSetPermissions(src, permission);
   }
 
-  void unprotectedSetPermission(String src, FsPermission permissions) {
+  void unprotectedSetPermission(String src, FsPermission permissions) throws FileNotFoundException
{
     synchronized(rootDir) {
-      rootDir.getNode(src).setPermission(permissions);
+        INode inode = rootDir.getNode(src);
+        if(inode == null)
+            throw new FileNotFoundException("File does not exist: " + src);
+        inode.setPermission(permissions);
     }
   }
 
@@ -418,9 +421,11 @@
     fsImage.getEditLog().logSetOwner(src, username, groupname);
   }
 
-  void unprotectedSetOwner(String src, String username, String groupname) {
+  void unprotectedSetOwner(String src, String username, String groupname) throws FileNotFoundException
{
     synchronized(rootDir) {
       INode inode = rootDir.getNode(src);
+      if(inode == null)
+          throw new FileNotFoundException("File does not exist: " + src);
       if (username != null) {
         inode.setUser(username);
       }

Modified: hadoop/core/branches/branch-0.16/src/test/org/apache/hadoop/security/TestPermission.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.16/src/test/org/apache/hadoop/security/TestPermission.java?rev=642336&r1=642335&r2=642336&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.16/src/test/org/apache/hadoop/security/TestPermission.java
(original)
+++ hadoop/core/branches/branch-0.16/src/test/org/apache/hadoop/security/TestPermission.java
Fri Mar 28 12:04:59 2008
@@ -119,6 +119,22 @@
     FileSystem fs = FileSystem.get(conf);
 
     try {
+        // test permissions on files that do not exist
+        assertFalse(fs.exists(CHILD_FILE1));
+        try {
+          fs.setOwner(CHILD_FILE1, "foo", "bar");
+          assertTrue(false);
+        }
+        catch(java.io.FileNotFoundException e) {
+          LOG.info("GOOD: got " + e);
+        }
+        try {
+          fs.setPermission(CHILD_FILE1, new FsPermission((short)0777));
+          assertTrue(false);
+        }
+        catch(java.io.FileNotFoundException e) {
+          LOG.info("GOOD: got " + e);
+        }
       // following dir/file creations are legal
       fs.mkdirs(CHILD_DIR1);
       FSDataOutputStream out = fs.create(CHILD_FILE1);



Mime
View raw message