diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 091c85f319c..8722cd981cb 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -648,6 +648,9 @@ Release 0.23.3 - UNRELEASED HADOOP-8573. Configuration tries to read from an inputstream resource multiple times (Robert Evans via tgraves) + 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 diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index b9339890c78..62b48cf7467 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -572,7 +572,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]; } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java index c85cc988627..ccf98ac44ed 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java +++ b/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);