[ 
https://issues.apache.org/jira/browse/HBASE-6991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13491751#comment-13491751
 ] 

Aditya Kishore commented on HBASE-6991:
---------------------------------------

[~yuzhih...@gmail.com], [~stack] Could you please review this.

https://reviews.apache.org/r/7632/
                
> 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

Reply via email to