You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/12/06 16:03:02 UTC
[hbase] branch branch-2 updated: HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewKeyValue() (#3904)
This is an automated email from the ASF dual-hosted git repository.
zhangduo 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 a5a8cd8 HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewKeyValue() (#3904)
a5a8cd8 is described below
commit a5a8cd8a631b5d682982cc18d6a611b79834409b
Author: Istvan Toth <st...@apache.org>
AuthorDate: Mon Dec 6 16:56:00 2021 +0100
HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewKeyValue() (#3904)
Signed-off-by: Andrew Purtell <ap...@apache.org>
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
index 8a17ce9..f155cb8 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
@@ -128,7 +128,11 @@ public class KeyValueUtil {
}
public static byte[] copyToNewByteArray(final Cell cell) {
- int v1Length = cell.getSerializedSize();
+ //Cell#getSerializedSize returns the serialized size of the Source cell, which may
+ //not serialize all fields. We are constructing a KeyValue backing array here,
+ //which does include all fields, and must allocate accordingly.
+ int v1Length = length(cell.getRowLength(), cell.getFamilyLength(),
+ cell.getQualifierLength(), cell.getValueLength(), cell.getTagsLength(), true);
byte[] backingBytes = new byte[v1Length];
appendToByteArray(cell, backingBytes, 0, true);
return backingBytes;