hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aditya Kishore (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HBASE-6991) Escape "\" in Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary()
Date Wed, 17 Oct 2012 04:52:05 GMT

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

Aditya Kishore updated HBASE-6991:
----------------------------------

    Summary: Escape "\" in Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary()
 (was: Bytes.toStringBinary() and its counterpart Bytes.toBytesBinary() are not always consistant)
    
> 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
>
> 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 unambiguity 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

Mime
View raw message