You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by sy...@apache.org on 2016/03/30 18:03:22 UTC
[20/50] [abbrv] hbase git commit: HBASE-15064
BufferUnderflowException after last Cell fetched from an HFile Block served
from L2 offheap cache - Addendum.
HBASE-15064 BufferUnderflowException after last Cell fetched from an HFile Block served from L2 offheap cache - Addendum.
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cadfb21f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cadfb21f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cadfb21f
Branch: refs/heads/hbase-12439
Commit: cadfb21f4bb465d1e305db2a159b8574282c8150
Parents: 5fcadb8
Author: anoopsjohn <an...@gmail.com>
Authored: Wed Mar 23 15:03:50 2016 +0530
Committer: anoopsjohn <an...@gmail.com>
Committed: Wed Mar 23 15:03:50 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/hbase/nio/MultiByteBuff.java | 3 ++-
.../hadoop/hbase/nio/TestMultiByteBuff.java | 25 ++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/cadfb21f/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
index ab2b5ea..107bb3f 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
@@ -472,7 +472,8 @@ public class MultiByteBuff extends ByteBuff {
*/
@Override
public final boolean hasRemaining() {
- return this.curItem.hasRemaining() || this.curItemIndex < this.items.length - 1;
+ return this.curItem.hasRemaining() || (this.curItemIndex < this.limitedItemIndex
+ && this.items[this.curItemIndex + 1].hasRemaining());
}
/**
http://git-wip-us.apache.org/repos/asf/hbase/blob/cadfb21f/hbase-common/src/test/java/org/apache/hadoop/hbase/nio/TestMultiByteBuff.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/nio/TestMultiByteBuff.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/nio/TestMultiByteBuff.java
index 800c8e1..af4c464 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/nio/TestMultiByteBuff.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/nio/TestMultiByteBuff.java
@@ -378,4 +378,29 @@ public class TestMultiByteBuff {
assertTrue(Bytes.equals(actual, 0, actual.length,
b, 1, 3));
}
+
+ @Test
+ public void testHasRemaining() {
+ ByteBuffer b1 = ByteBuffer.allocate(8);
+ ByteBuffer b2 = ByteBuffer.allocate(8);
+ ByteBuffer b3 = ByteBuffer.allocate(8);
+ MultiByteBuff mbb1 = new MultiByteBuff(b1, b2, b3);
+ assertTrue(mbb1.hasRemaining());
+ mbb1.limit(20); // Limit in mid of last of BB
+ mbb1.position(15);
+ mbb1.get();// We are at the end of second BB
+ assertTrue(mbb1.hasRemaining());
+ mbb1.position(20);
+ assertFalse(mbb1.hasRemaining());
+ mbb1.limit(12); // Limit in mid of second BB
+ mbb1.position(11);
+ assertTrue(mbb1.hasRemaining());
+ mbb1.get(); // Now we have reached the limit
+ assertFalse(mbb1.hasRemaining());
+ mbb1.limit(16);// Limit at begin of the last BB
+ mbb1.position(15);
+ assertTrue(mbb1.hasRemaining());
+ mbb1.get(); // Now we have reached the limit
+ assertFalse(mbb1.hasRemaining());
+ }
}