You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/08/02 22:08:31 UTC
svn commit: r1509842 -
/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
Author: stack
Date: Fri Aug 2 20:08:30 2013
New Revision: 1509842
URL: http://svn.apache.org/r1509842
Log:
HBASE-9031 ImmutableBytesWritable.toString() should downcast the bytes before converting to hex string
Modified:
hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
Modified: hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java?rev=1509842&r1=1509841&r2=1509842&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java (original)
+++ hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java Fri Aug 2 20:08:30 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.