[ https://issues.apache.org/jira/browse/HBASE-6991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13491808#comment-13491808 ]
Hudson commented on HBASE-6991: ------------------------------- Integrated in HBase-TRUNK #3514 (See [https://builds.apache.org/job/HBase-TRUNK/3514/]) HBASE-6991 Escape "\" in Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary() (Revision 1406297) Result = SUCCESS stack : Files : * /hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java * /hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java * /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBlock.java * /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBlockCompatibility.java > Escape "\" in Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary() > ------------------------------------------------------------------------------ > > Key: HBASE-6991 > URL: https://issues.apache.org/jira/browse/HBASE-6991 > Project: HBase > Issue Type: Bug > Components: util > Affects Versions: 0.96.0 > Reporter: Aditya Kishore > Assignee: Aditya Kishore > Fix For: 0.96.0 > > Attachments: HBASE-6991_trunk.patch > > > 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. > {code} > 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 > {code} > 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. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira