HBASE-15064 BufferUnderflowException after last Cell fetched from an HFile Block served from L2 offheap cache - Addendum.
This commit is contained in:
parent
5fcadb86ab
commit
cadfb21f4b
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue