Browse Source

HADOOP-2934. The namenode was encountreing a NPE while loading
leases from the fsimage. Fixed. (dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@633965 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 17 years ago
parent
commit
c41bd9c9ef

+ 3 - 0
CHANGES.txt

@@ -137,6 +137,9 @@ Trunk (unreleased changes)
     HADOOP-2821. Removes deprecated ShellUtil and ToolBase classes from
     the util package. (Amareshwari Sri Ramadasu via ddas) 
 
+    HADOOP-2934. The namenode was encountreing a NPE while loading
+    leases from the fsimage. Fixed. (dhruba)
+
 Release 0.16.1 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 4 - 2
src/java/org/apache/hadoop/dfs/FSImage.java

@@ -946,10 +946,11 @@ class FSImage extends Storage {
     long preferredBlockSize = in.readLong();
     int numBlocks = in.readInt();
     BlockInfo[] blocks = new BlockInfo[numBlocks];
+    Block blk = new Block();
     for (int i = 0; i < numBlocks; i++) {
-      blocks[i].readFields(in);
+      blk.readFields(in);
+      blocks[i] = new BlockInfo(blk, blockReplication);
     }
-
     PermissionStatus perm = PermissionStatus.read(in);
     UTF8 clientName = new UTF8();
     clientName.readFields(in);
@@ -959,6 +960,7 @@ class FSImage extends Storage {
     int numLocs = in.readInt();
     DatanodeDescriptor[] locations = new DatanodeDescriptor[numLocs];
     for (int i = 0; i < numLocs; i++) {
+      locations[i] = new DatanodeDescriptor();
       locations[i].readFields(in);
     }
 

+ 1 - 0
src/test/org/apache/hadoop/dfs/TestFileCreation.java

@@ -357,6 +357,7 @@ public class TestFileCreation extends TestCase {
       System.out.println("testFileCreationNamenodeRestart: "
                          + "Created file filestatus.dat with one "
                          + " replicas.");
+      writeFile(stm);
 
       // create another new file.
       //