Skip to content
Permalink
Browse files
HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewK…
…eyValue() (#3904)

Signed-off-by: Andrew Purtell <apurtell@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
stoty committed Dec 6, 2021
1 parent 9cf224d commit d9315fa04311f0c9d857731226bf640b4212f814
Showing 1 changed file with 5 additions and 1 deletion.
@@ -128,7 +128,11 @@ public static KeyValue toNewKeyCell(final Cell cell) {
}

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;

0 comments on commit d9315fa

Please sign in to comment.