From 1f9bf419c1c9040504de1b36fb85d0be7163eadf Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Sun, 5 Jul 2015 12:28:27 -0700 Subject: [PATCH] HBASE-13329 ArrayIndexOutOfBoundsException in CellComparator#getMinimumMidpointArray. --- .../hbase/io/hfile/HFileWriterImpl.java | 2 +- .../hbase/regionserver/TestHRegion.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java index 42b94d46365..fcb264dbaa8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java @@ -431,7 +431,7 @@ public class HFileWriterImpl implements HFile.Writer { final int leftLength, 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++; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index bd6d452d24d..23f5e48e5df 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -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 // ////////////////////////////////////////////////////////////////////////////