HBASE-26527 ArrayIndexOutOfBoundsException in KeyValueUtil.copyToNewKeyValue() (#3904)
Signed-off-by: Andrew Purtell <apurtell@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
ec52519f7c
commit
a5a8cd8a63
|
@ -128,7 +128,11 @@ public class KeyValueUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] copyToNewByteArray(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];
|
byte[] backingBytes = new byte[v1Length];
|
||||||
appendToByteArray(cell, backingBytes, 0, true);
|
appendToByteArray(cell, backingBytes, 0, true);
|
||||||
return backingBytes;
|
return backingBytes;
|
||||||
|
|
Loading…
Reference in New Issue