Details
Description
Since "\" is used to escape non-printable character but not treated as special character in conversion, it could lead to unexpected conversion.
For example, please consider the following code snippet.
public void testConversion() { byte[] original = { '\\', 'x', 'A', 'D' }; String stringFromBytes = Bytes.toStringBinary(original); byte[] converted = Bytes.toBytesBinary(stringFromBytes); System.out.println("Original: " + Arrays.toString(original)); System.out.println("Converted: " + Arrays.toString(converted)); System.out.println("Reversible?: " + (Bytes.compareTo(original, converted) == 0)); } Output: ------- Original: [92, 120, 65, 68] Converted: [-83] Reversible?: false
The "\" character needs to be treated as special and must be encoded as a non-printable character ("\x5C") to avoid any kind of ambiguity during conversion.
Attachments
Attachments
Issue Links
- is related to
-
HBASE-8085 Backport the fix for Bytes.toStringBinary() into 94 (HBASE-6991)
- Closed