浏览代码

Fix for HADOOP-40. Buffer position was not maintained correctly. Contributed by Konstantin Shvachko.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@380042 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 19 年之前
父节点
当前提交
80254201e5
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/java/org/apache/hadoop/fs/FSDataInputStream.java

+ 3 - 2
src/java/org/apache/hadoop/fs/FSDataInputStream.java

@@ -154,8 +154,9 @@ public class FSDataInputStream extends DataInputStream {
     // This is the only read() method called by BufferedInputStream, so we trap
     // calls to it in order to cache the position.
     public int read(byte b[], int off, int len) throws IOException {
-      int result = in.read(b, off, len);
-      position += result;
+      int result;
+      if( (result = in.read(b, off, len)) > 0 )
+        position += result;
       return result;
     }