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-2@1362296 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-07-16 22:41:59 +00:00
parent 551ed65482
commit 2b81fe68b7
3 changed files with 5 additions and 1 deletions

View File

@ -648,6 +648,9 @@ Release 0.23.3 - UNRELEASED
HADOOP-8573. Configuration tries to read from an inputstream resource HADOOP-8573. Configuration tries to read from an inputstream resource
multiple times (Robert Evans via tgraves) 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 Release 0.23.2 - UNRELEASED
NEW FEATURES NEW FEATURES

View File

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

View File

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