hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r666056 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/dfs/FSDirectory.java src/test/org/apache/hadoop/dfs/TestDFSRename.java src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java
Date Tue, 10 Jun 2008 10:14:59 GMT
Author: tomwhite
Date: Tue Jun 10 03:14:57 2008
New Revision: 666056

URL: http://svn.apache.org/viewvc?rev=666056&view=rev
Log:
HADOOP-3519.  Fix NPE in DFS FileSystem rename.  Contributed by hairong.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/FSDirectory.java
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSRename.java
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=666056&r1=666055&r2=666056&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Jun 10 03:14:57 2008
@@ -558,6 +558,8 @@
 
     HADOOP-3513. Improve NNThroughputBenchmark log messages. (shv)
 
+    HADOOP-3519.  Fix NPE in DFS FileSystem rename.  (hairong via tomwhite)
+
 Release 0.17.0 - 2008-05-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/FSDirectory.java?rev=666056&r1=666055&r2=666056&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/FSDirectory.java Tue Jun 10 03:14:57
2008
@@ -363,10 +363,16 @@
       INode[] dstInodes = new INode[dstComponents.length];
       rootDir.getExistingPathINodes(dstComponents, dstInodes);
       
-      // check the existence of the destination
-      if (dstInodes[dstInodes.length-1] != null) {
+      // check the validity of the destination
+      if (dstInodes[dstInodes.length-1] != null) { //check if destination exists
         NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
-                                     +"failed to rename "+src+" to "+dst+ " because destination
exists");
+                                     +"failed to rename "+src+" to "+dst+ 
+                                     " because destination exists");
+        return false;
+      } else if (dstInodes[dstInodes.length-2] == null) { // check if its parent exists
+        NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
+            +"failed to rename "+src+" to "+dst+ 
+            " because destination's parent does not exists");
         return false;
       }
       

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSRename.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSRename.java?rev=666056&r1=666055&r2=666056&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSRename.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSRename.java Tue Jun 10 03:14:57
2008
@@ -71,6 +71,11 @@
       //should not have any lease
       assertEquals(0, countLease(cluster)); 
 
+      // test non-existent destination
+      Path dstPath = new Path("/c/d");
+      assertFalse(fs.exists(dstPath));
+      assertFalse(fs.rename(dir, dstPath));
+      
       fs.delete(dir, true);
     } finally {
       if (cluster != null) {cluster.shutdown();}

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java?rev=666056&r1=666055&r2=666056&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestHDFSFileSystemContract.java Tue Jun
10 03:14:57 2008
@@ -38,10 +38,4 @@
     cluster.shutdown();
   }
   
-  @Override
-  protected boolean renameSupported() {
-    // disable for the moment as rename tests are not working on HDFS yet
-    return false;
-  }
-
 }



Mime
View raw message