hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r1054807 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/DFSUtil.java src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java
Date Mon, 03 Jan 2011 22:22:03 GMT
Author: hairong
Date: Mon Jan  3 22:22:03 2011
New Revision: 1054807

URL: http://svn.apache.org/viewvc?rev=1054807&view=rev
Log:
HDFS-1550. NPE when listing a file with no location. Contributed by Hairong Kuang.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSUtil.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1054807&r1=1054806&r2=1054807&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon Jan  3 22:22:03 2011
@@ -471,6 +471,8 @@ Release 0.22.0 - Unreleased
     HDFS-1560. dfs.data.dir permissions should default to 700. 
     (Todd Lipcon via eli)
 
+    HDFS-1550. NPE when listing a file with no location. (hairong)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSUtil.java?rev=1054807&r1=1054806&r2=1054807&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSUtil.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSUtil.java Mon Jan  3 22:22:03 2011
@@ -204,6 +204,9 @@ public class DFSUtil {
     }
     int nrBlocks = blocks.locatedBlockCount();
     BlockLocation[] blkLocations = new BlockLocation[nrBlocks];
+    if (nrBlocks == 0) {
+      return blkLocations;
+    }
     int idx = 0;
     for (LocatedBlock blk : blocks.getLocatedBlocks()) {
       assert idx < nrBlocks : "Incorrect index";

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java?rev=1054807&r1=1054806&r2=1054807&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUtil.java Mon Jan  3 22:22:03
2011
@@ -19,6 +19,8 @@
 package org.apache.hadoop.hdfs;
 
 import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
@@ -65,5 +67,9 @@ public class TestDFSUtil {
 
     assertTrue("expected 1 corrupt files but got " + corruptCount, 
                corruptCount == 1);
+    
+    // test an empty location
+    bs = DFSUtil.locatedBlocks2Locations(new LocatedBlocks());
+    assertEquals(0, bs.length);
   }
 }
\ No newline at end of file



Mime
View raw message