hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1509840 - /hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
Date Fri, 02 Aug 2013 20:08:13 GMT
Author: stack
Date: Fri Aug  2 20:08:12 2013
New Revision: 1509840

URL: http://svn.apache.org/r1509840
Log:
HBASE-9031 ImmutableBytesWritable.toString() should downcast the bytes before converting to
hex string

Modified:
    hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java

Modified: hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java?rev=1509840&r1=1509839&r2=1509840&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
(original)
+++ hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
Fri Aug  2 20:08:12 2013
@@ -212,20 +212,18 @@ implements WritableComparable<ImmutableB
    */
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder(3*this.bytes.length);
-    for (int idx = offset; idx < offset + length; idx++) {
-      // if not the first, put a blank separator in
-      if (idx != offset) {
-        sb.append(' ');
-      }
-      String num = Integer.toHexString(bytes[idx]);
+    StringBuilder sb = new StringBuilder(3*this.length);
+    final int endIdx = this.offset + this.length;
+    for (int idx = this.offset; idx < endIdx ; idx++) {
+      sb.append(' ');
+      String num = Integer.toHexString(0xff & this.bytes[idx]);
       // if it is only one digit, add a leading 0.
       if (num.length() < 2) {
         sb.append('0');
       }
       sb.append(num);
     }
-    return sb.toString();
+    return sb.length() > 0 ? sb.substring(1) : "";
   }
 
   /** A Comparator optimized for ImmutableBytesWritable.



Mime
View raw message