HBASE-13329 ArrayIndexOutOfBoundsException in CellComparator#getMinimumMidpointArray.

This commit is contained in:
Lars Hofhansl 2015-07-05 12:28:27 -07:00
parent 215290eb76
commit 1f9bf419c1
2 changed files with 25 additions and 1 deletions

View File

@ -431,7 +431,7 @@ public class HFileWriterImpl implements HFile.Writer {
final int leftLength, final byte[] rightArray, final int rightOffset, final int rightLength) { final int leftLength, final byte[] rightArray, final int rightOffset, final int rightLength) {
// rows are different // rows are different
int minLength = leftLength < rightLength ? leftLength : rightLength; int minLength = leftLength < rightLength ? leftLength : rightLength;
short diffIdx = 0; int diffIdx = 0;
while (diffIdx < minLength while (diffIdx < minLength
&& leftArray[leftOffset + diffIdx] == rightArray[rightOffset + diffIdx]) { && leftArray[leftOffset + diffIdx] == rightArray[rightOffset + diffIdx]) {
diffIdx++; diffIdx++;

View File

@ -3366,6 +3366,30 @@ public class TestHRegion {
} }
} }
/**
* 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.flush(false);
HBaseTestingUtility.closeRegionAndWAL(this.region);
this.region = null;
}
// //////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////
// Split test // Split test
// //////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////