You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Enis Soztutar (JIRA)" <ji...@apache.org> on 2013/03/14 03:36:14 UTC

[jira] [Updated] (HBASE-6991) Escape "\" in Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary()

     [ https://issues.apache.org/jira/browse/HBASE-6991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HBASE-6991:
---------------------------------

    Release Note: 
This patch changes Bytes.toStringBinary() and Bytes.toBytesBinary() to escape the character "\". Unprintable characters are escaped using "\\x%02X" format, but "\" was not escaped properly leading to irreversible ser/de using toStringBinary() -> toBytesBinary().

    
> 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.95.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