Skip to content

Commit

Permalink
HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewK…
Browse files Browse the repository at this point in the history
…eyValue() (apache#3904)

Signed-off-by: Andrew Purtell <[email protected]>
Signed-off-by: Duo Zhang <[email protected]>
  • Loading branch information
stoty authored Dec 6, 2021
1 parent 9cf224d commit d9315fa
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d9315fa

Please sign in to comment.