Apache9 commented on code in PR #4647:
URL: https://github.com/apache/hbase/pull/4647#discussion_r929515265


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java:
##########
@@ -495,6 +494,21 @@ public static String toString(final byte[] b) {
     return toString(b, 0, b.length);
   }
 
+  /**
+   * Returns String made from <code>b</code>
+   */
+  public static String toString(ByteBuffer buf) {
+    if (buf == null) {
+      return null;
+    }
+    if (!buf.hasArray()) {
+      buf = ByteBuffer.wrap(buf.array(), buf.arrayOffset(), buf.remaining());

Review Comment:
   I mean here, if the buf is not array backed, we should create a byte array, 
copy the content to it and then call toString(byte[])?
   
   Here we test `!buf.hasArray()`, but then we still call `buf.array()`...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to