浏览代码

HADOOP-8599. Non empty response from FileSystem.getFileBlockLocations when asking for data beyond the end of file. Contributed by Andrey Klochkov.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1362297 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 13 年之前
父节点
当前提交
3ee301eca5

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -111,6 +111,9 @@ Release 0.23.3 - UNRELEASED
 
     HADOOP-8587. HarFileSystem access of harMetaCache isn't threadsafe. (eli)
 
+    HADOOP-8599. Non empty response from FileSystem.getFileBlockLocations when
+    asking for data beyond the end of file. (Andrey Klochkov via todd)
+
 Release 0.23.2 - UNRELEASED 
 
   NEW FEATURES

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java

@@ -564,7 +564,7 @@ public abstract class FileSystem extends Configured implements Closeable {
       throw new IllegalArgumentException("Invalid start or len parameter");
     }
 
-    if (file.getLen() < start) {
+    if (file.getLen() <= start) {
       return new BlockLocation[0];
 
     }

+ 1 - 0
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java

@@ -122,6 +122,7 @@ public class TestGetFileBlockLocations extends TestCase {
     oneTest(0, (int) status.getLen() * 2, status);
     oneTest((int) status.getLen() * 2, (int) status.getLen() * 4, status);
     oneTest((int) status.getLen() / 2, (int) status.getLen() * 3, status);
+    oneTest((int) status.getLen(), (int) status.getLen() * 2, status);
     for (int i = 0; i < 10; ++i) {
       oneTest((int) status.getLen() * i / 10, (int) status.getLen() * (i + 1)
           / 10, status);