This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/3.1 by this push:
     new 5cebf6ba17 removes bare usage of Text.getBytes() (#4895)
5cebf6ba17 is described below

commit 5cebf6ba17bc772e6df81ff1d5c4cc84e3ae3192
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Fri Sep 20 16:37:51 2024 -0400

    removes bare usage of Text.getBytes() (#4895)
    
    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.
---
 core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java 
b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
index 296a26ed33..150fcf4757 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
@@ -1711,7 +1711,7 @@ public class RFile {
 
       // 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);

Reply via email to