Skip to content

Commit

Permalink
HBASE-13329 ArrayIndexOutOfBoundsException in CellComparator#getMinim…
Browse files Browse the repository at this point in the history
…umMidpointArray.
  • Loading branch information
lhofhansl committed Jul 5, 2015
1 parent ec4ff44 commit 4b934b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public static Cell getMidpoint(final KeyValue.KVComparator comparator, final Cel
final byte [] rightArray, final int rightOffset, final int rightLength) {
// rows are different
int minLength = leftLength < rightLength ? leftLength : rightLength;
short diffIdx = 0;
int diffIdx = 0;
while (diffIdx < minLength &&
leftArray[leftOffset + diffIdx] == rightArray[rightOffset + diffIdx]) {
diffIdx++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3306,6 +3306,30 @@ public boolean isFamilyEssential(byte[] name) {
}
}

/**
* Write an HFile block full with Cells whose qualifier that are identical between
* 0 and Short.MAX_VALUE. See HBASE-13329.
* @throws Exception
*/
@Test
public void testLongQualifier() throws Exception {
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family);
byte[] q = new byte[Short.MAX_VALUE+2];
Arrays.fill(q, 0, q.length-1, (byte)42);
for (byte i=0; i<10; i++) {
Put p = new Put(Bytes.toBytes("row"));
// qualifiers that differ past Short.MAX_VALUE
q[q.length-1]=i;
p.addColumn(family, q, q);
region.put(p);
}
region.flushcache();
HRegion.closeHRegion(this.region);
this.region = null;
}
// ////////////////////////////////////////////////////////////////////////////
// Split test
// ////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 4b934b5

Please sign in to comment.