From e29170e771e8dac28d0fd846e6459db4baf0fcd8 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Tue, 14 May 2013 15:16:12 +0000 Subject: [PATCH] HADOOP-9307. BufferedFSInputStream.read returns wrong results after certain seeks. Contributed by Todd Lipcon. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1482377 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 + .../hadoop/fs/BufferedFSInputStream.java | 17 +++-- .../apache/hadoop/fs/TestLocalFileSystem.java | 73 ++++++++++++++++++- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c55f1621737..8d99d0bc63e 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -717,6 +717,9 @@ Release 2.0.5-beta - UNRELEASED Service HEALTHY, and results in null data at ActiveBreadCrumb. (Vinay and todd via todd) + HADOOP-9307. BufferedFSInputStream.read returns wrong results + after certain seeks. (todd) + Release 2.0.4-alpha - 2013-04-25 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BufferedFSInputStream.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BufferedFSInputStream.java index 745148281d2..be86ae84cd3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BufferedFSInputStream.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BufferedFSInputStream.java @@ -69,12 +69,17 @@ implements Seekable, PositionedReadable, HasFileDescriptor { if( pos<0 ) { return; } - // optimize: check if the pos is in the buffer - long end = ((FSInputStream)in).getPos(); - long start = end - count; - if( pos>=start && pos=start && pos