You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2019/10/04 13:32:50 UTC

[hbase] branch branch-2 updated: HBASE-23119 ArrayIndexOutOfBoundsException in PrivateCellUtil#qualifierStartsWith (#688)

This is an automated email from the ASF dual-hosted git repository.

psomogyi pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new e3078aa  HBASE-23119 ArrayIndexOutOfBoundsException in PrivateCellUtil#qualifierStartsWith (#688)
e3078aa is described below

commit e3078aa5aa0e70a5f22846cc048d6a5722a96535
Author: Istvan Toth <st...@users.noreply.github.com>
AuthorDate: Fri Oct 4 15:13:03 2019 +0200

    HBASE-23119 ArrayIndexOutOfBoundsException in PrivateCellUtil#qualifierStartsWith (#688)
    
    Signed-off-by: Peter Somogyi <ps...@apache.org>
    Signed-off-by: Viraj Jasani <vi...@gmail.com>
---
 .../test/java/org/apache/hadoop/hbase/filter/TestComparators.java | 8 ++++++++
 .../src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java    | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
index 7a4f970..3835948 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.filter;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteBuffer;
@@ -97,5 +98,12 @@ public class TestComparators {
     comparable = new SubstringComparator("cf");
     assertEquals(0, PrivateCellUtil.compareFamily(bbCell, comparable));
     assertEquals(0, PrivateCellUtil.compareFamily(kv, comparable));
+    // Qualifier starts with
+    kv = new KeyValue(r1, f, q1, v2);
+    assertTrue(PrivateCellUtil.qualifierStartsWith(kv, Bytes.toBytes("q")));
+    assertTrue(PrivateCellUtil.qualifierStartsWith(kv, q1));
+    assertFalse(PrivateCellUtil.qualifierStartsWith(kv, q2));
+    assertFalse(PrivateCellUtil.qualifierStartsWith(kv, Bytes.toBytes("longerthanthequalifier")));
   }
+
 }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
index 768ab00..c26841d 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
@@ -767,6 +767,9 @@ public final class PrivateCellUtil {
     if (startsWith == null || startsWith.length == 0) {
       throw new IllegalArgumentException("Cannot pass an empty startsWith");
     }
+    if (left.getQualifierLength() < startsWith.length) {
+      return false;
+    }
     if (left instanceof ByteBufferExtendedCell) {
       return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
           ((ByteBufferExtendedCell) left).getQualifierPosition(), startsWith.length,