Bläddra i källkod

HDFS-2451. TestNodeCount.testNodeCount failes with NPE. Contributed by Konstantin Boudnik.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1186556 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Boudnik 13 år sedan
förälder
incheckning
ad97e6935e

+ 2 - 0
hdfs/CHANGES.txt

@@ -648,6 +648,8 @@ Release 0.22.0 - Unreleased
     HDFS-2286. DataXceiverServer logs AsynchronousCloseException at shutdown
     (Todd Lipcon and Uma Maheswara Rao G via shv)
 
+    HDFS-2451. TestNodeCount.testNodeCount failes with NPE (cos)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

+ 5 - 1
hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNodeCount.java

@@ -107,7 +107,9 @@ public class TestNodeCount extends TestCase {
       
       // The block should be replicated
       do {
+        namesystem.writeLock();
         num = namesystem.blockManager.countNodes(block);
+        namesystem.writeUnlock();
       } while (num.liveReplicas() != REPLICATION_FACTOR);
       
       // restart the first datanode
@@ -116,7 +118,9 @@ public class TestNodeCount extends TestCase {
       
       // check if excessive replica is detected
       do {
-       num = namesystem.blockManager.countNodes(block);
+        namesystem.writeLock();
+        num = namesystem.blockManager.countNodes(block);
+        namesystem.writeUnlock();
       } while (num.excessReplicas() != 2);
     } finally {
       cluster.shutdown();