Browse Source

HADOOP-8612. Backport HADOOP-8599 to branch-1 (Non empty response when read beyond eof). Contributed by Andrey Klochkov

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1364801 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 năm trước cách đây
mục cha
commit
41d107ca69

+ 3 - 0
CHANGES.txt

@@ -99,6 +99,9 @@ Release 1.2.0 - unreleased
     HDFS-3698. TestHftpFileSystem is failing in branch-1 due to changed
     default secure port. (atm)
 
+    HADOOP-8612. Backport HADOOP-8599 to branch-1 (Non empty response
+    when read beyond eof). (Andrey Klochkov, eli via eli)
+
 Release 1.1.0 - unreleased
 
   INCOMPATIBLE CHANGES

+ 1 - 1
src/core/org/apache/hadoop/fs/FileSystem.java

@@ -402,7 +402,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
src/test/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);