From f4a21d3abaa7c5a9f0a0d8417e81f7eaf3d1b29a Mon Sep 17 00:00:00 2001 From: Kai Zheng Date: Sat, 27 Aug 2016 10:54:25 +0800 Subject: [PATCH] HDFS-10795. Fix an error in ReaderStrategy#ByteBufferStrategy. Contributed by Sammi Chen --- .../src/main/java/org/apache/hadoop/hdfs/ReaderStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ReaderStrategy.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ReaderStrategy.java index d75a8ef653c..c984c3b7322 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ReaderStrategy.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ReaderStrategy.java @@ -181,7 +181,7 @@ class ByteBufferStrategy implements ReaderStrategy { int length) throws IOException { ByteBuffer tmpBuf = readBuf.duplicate(); tmpBuf.limit(tmpBuf.position() + length); - int nRead = blockReader.read(readBuf.slice()); + int nRead = blockReader.read(tmpBuf); // Only when data are read, update the position if (nRead > 0) { readBuf.position(readBuf.position() + nRead);