Skip to content

Commit

Permalink
removes bare usage of Text.getBytes()
Browse files Browse the repository at this point in the history
Calls to Text.getBytes() should always be accompanied with a call to
getLength() because an array that is longer than the data could be
returned if set() was ever called on the Text object.

Replaced with a call to getRowData().toArray() that is more efficient
and does not have the length problem.

Did a partial review of the code and found this one case.  Could be
other cases like this lurking.
  • Loading branch information
keith-turner committed Sep 17, 2024
1 parent 9f8c069 commit 4d89fd6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ private Key getEndKey(Key key) {

// If exclusive we need to strip the last byte to get the last key that is part of the
// actual range to return
final byte[] ba = key.getRow().getBytes();
final byte[] ba = key.getRowData().toArray();
Preconditions.checkArgument(ba.length > 0 && ba[ba.length - 1] == (byte) 0x00);
byte[] fba = new byte[ba.length - 1];
System.arraycopy(ba, 0, fba, 0, ba.length - 1);
Expand Down

0 comments on commit 4d89fd6

Please sign in to comment.