You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Prakash Khemani (JIRA)" <ji...@apache.org> on 2011/01/14 18:15:45 UTC

[jira] Created: (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
--------------------------------------------------------------------

                 Key: HBASE-3444
                 URL: https://issues.apache.org/jira/browse/HBASE-3444
             Project: HBase
          Issue Type: Bug
            Reporter: Prakash Khemani
            Priority: Minor


Bytes.toStringBinary() doesn't escape \.

Otherwise the transformation isn't reversible

byte[] a = {'\', 'x' , '0', '0'}

Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Updated] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ted Yu updated HBASE-3444:
--------------------------

    Status: Open  (was: Patch Available)
    
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Updated] (HBASE-3444) Test to prove Bytes.toBytesBinary and Bytes.toStringBinary() is reversible

Posted by "stack (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

stack updated HBASE-3444:
-------------------------

    Summary: Test to prove Bytes.toBytesBinary and Bytes.toStringBinary()  is reversible  (was: Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible)
    
> Test to prove Bytes.toBytesBinary and Bytes.toStringBinary()  is reversible
> ---------------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444-testonly.txt, 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475253#comment-13475253 ] 

Ted Yu commented on HBASE-3444:
-------------------------------

No the patch is not the same as current code. See this boundary check:
{code}
+        char next = i+1 < in.length() ? in.charAt(i+1) : ch; // check for array out of bounds
{code}
Without the above, in.charAt(i+1) would produce ArrayIndexOutOfBoundsException

Thanks
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473375#comment-13473375 ] 

Ted Yu commented on HBASE-3444:
-------------------------------

I would choose "Modify Bytes.toBytesBinary to consider standalone '\'"
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Test to prove Bytes.toBytesBinary and Bytes.toStringBinary() is reversible

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475442#comment-13475442 ] 

Hudson commented on HBASE-3444:
-------------------------------

Integrated in HBase-TRUNK-on-Hadoop-2.0.0 #220 (See [https://builds.apache.org/job/HBase-TRUNK-on-Hadoop-2.0.0/220/])
    HBASE-3444 Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible (Revision 1397703)

     Result = FAILURE
stack : 
Files : 
* /hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java

                
> Test to prove Bytes.toBytesBinary and Bytes.toStringBinary()  is reversible
> ---------------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444-testonly.txt, 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "stack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475254#comment-13475254 ] 

stack commented on HBASE-3444:
------------------------------

What is the trunk issue [~jxiang]?  Is this a dup then?
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Jimmy Xiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475246#comment-13475246 ] 

Jimmy Xiang commented on HBASE-3444:
------------------------------------

To me, the patch moved the second part of the condition inside the block, so essentially, it is the same, right?
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Updated] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "stack (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

stack updated HBASE-3444:
-------------------------

    Attachment: 3444-testonly.txt

Here is test only from the patch.  When I run it on trunk it passes.  Let me commit the test as part of this issue.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444-testonly.txt, 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ken Dallmeyer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473344#comment-13473344 ] 

Ken Dallmeyer commented on HBASE-3444:
--------------------------------------

I was looking into a way to fix this so that I can make it reversible.  The main problem as I see is that the '\' character is both a printable character in Bytes.toStringBinary and an indicator for hex characters in Bytes.toBytesBinary.  Either Bytes.toStringBinary should not consider '\' as printable OR Bytes.toBytesBinary should handle lone '\' cases where it doesn't prefix a hex number.

Below are modifications to two methods that handle either case.  Whichever one you choose, you don't have to choose the other.

# *Modify Bytes.toStringBinary to not consider '\' as a printable character*
Removes \\ from the if statement
{code}
  public static String toStringBinary(final byte [] b, int off, int len) {
    StringBuilder result = new StringBuilder();
    try {
      String first = new String(b, off, len, "ISO-8859-1");
      for (int i = 0; i < first.length() ; ++i ) {
        int ch = first.charAt(i) & 0xFF;
        if ( (ch >= '0' && ch <= '9')
            || (ch >= 'A' && ch <= 'Z')
            || (ch >= 'a' && ch <= 'z')
            || " `~!@#$%^&*()-_=+[]{}|;:'\",.<>/?".indexOf(ch) >= 0 ) { // Change made here to remove '\\'
          result.append(first.charAt(i));
        } else {
          result.append(String.format("\\x%02X", ch));
        }
      }
    } catch (UnsupportedEncodingException e) {
      System.err.println("ISO-8859-1 not supported?");
    }
    return result.toString();
  }
{code}

# *Modify Bytes.toBytesBinary to consider standalone '\'*
The problem is that the last '\' is causing out of bounds issues.  Just check to see if there is more to the array.
{code}
    public static byte [] toBytesBinary(String in) {
      // this may be bigger than we need, but lets be safe.
      byte [] b = new byte[in.length()];
      int size = 0;
      for (int i = 0; i < in.length(); ++i) {
        char ch = in.charAt(i);
        if (ch == '\\') {
          // begin hex escape:
          char next = i+1 < in.length() ? in.charAt(i+1) : ch; // Change made here to check for array out of bounds
          if (next != 'x') {
            // invalid escape sequence, ignore this one.
            b[size++] = (byte)ch;
            continue;
          }
          // ok, take next 2 hex digits.
          char hd1 = in.charAt(i+2);
          char hd2 = in.charAt(i+3);

          // they need to be A-F0-9:
          if (!isHexDigit(hd1) ||
              !isHexDigit(hd2)) {
            // bogus escape code, ignore:
            continue;
          }
          // turn hex ASCII digit -> number
          byte d = (byte) ((toBinaryFromHex((byte)hd1) << 4) + toBinaryFromHex((byte)hd2));

          b[size++] = d;
          i += 3; // skip 3
        } else {
          b[size++] = (byte) ch;
        }
      }
      // resize:
      byte [] b2 = new byte[size];
      System.arraycopy(b, 0, b2, 0, size);
      return b2;
    }
{code}

# *Test case for both*
{code}
    public void testToStringBinary_toBytesBinary_Reversable() throws Exception {
        String bytes = Bytes.toStringBinary(Bytes.toBytes(2.17));
        assertEquals(2.17, Bytes.toDouble(Bytes.toBytesBinary(bytes)), 0);        
    }
{code}
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Updated] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ted Yu updated HBASE-3444:
--------------------------

    Fix Version/s: 0.96.0
           Status: Patch Available  (was: Open)
    
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "stack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473837#comment-13473837 ] 

stack commented on HBASE-3444:
------------------------------

I agree that we should change toBytesBinary.  Mind making a patch [~dallmkp]?  Thanks for looking at this.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Updated] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "stack (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

stack updated HBASE-3444:
-------------------------

    Tags: noob
    
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ted Yu reassigned HBASE-3444:
-----------------------------

    Assignee: Ken Dallmeyer
    
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Steve Hoffman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473355#comment-13473355 ] 

Steve Hoffman commented on HBASE-3444:
--------------------------------------

Nice work Ken.  Hopefully this will get picked up soon.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Updated] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ted Yu updated HBASE-3444:
--------------------------

    Attachment: 3444.txt

Patch based on the code Ken posted.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Simon Kelly (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13245089#comment-13245089 ] 

Simon Kelly commented on HBASE-3444:
------------------------------------

Also results in java.lang.StringIndexOutOfBoundsException in Bytes.toBytesBinary if the byte[] ends in a '\'

{code}
byte[] bytes = new byte[]{'a','b','c','\'};
Bytes.toBytesBinary(Bytes.toStringBinary(bytes));
{code}
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "stack (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13245384#comment-13245384 ] 

stack commented on HBASE-3444:
------------------------------

Do you have a patch for us Simon?  Thanks.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Priority: Minor
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-3444) Test to prove Bytes.toBytesBinary and Bytes.toStringBinary() is reversible

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475357#comment-13475357 ] 

Hudson commented on HBASE-3444:
-------------------------------

Integrated in HBase-TRUNK #3446 (See [https://builds.apache.org/job/HBase-TRUNK/3446/])
    HBASE-3444 Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible (Revision 1397703)

     Result = FAILURE
stack : 
Files : 
* /hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java

                
> Test to prove Bytes.toBytesBinary and Bytes.toStringBinary()  is reversible
> ---------------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444-testonly.txt, 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Resolved] (HBASE-3444) Test to prove Bytes.toBytesBinary and Bytes.toStringBinary() is reversible

Posted by "stack (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

stack resolved HBASE-3444.
--------------------------

      Resolution: Fixed
    Hadoop Flags: Reviewed

Committed the test only.   It proves that HBASE-6518 works.  Thanks for the patch Ken.
                
> Test to prove Bytes.toBytesBinary and Bytes.toStringBinary()  is reversible
> ---------------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444-testonly.txt, 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Jimmy Xiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475196#comment-13475196 ] 

Jimmy Xiang commented on HBASE-3444:
------------------------------------

This patch looks the same as what we have in trunk:

{noformat}
 if (ch == '\\' && in.length() > i+1 && in.charAt(i+1) == 'x') 
{noformat}

Did I miss anything?
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Jimmy Xiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475263#comment-13475263 ] 

Jimmy Xiang commented on HBASE-3444:
------------------------------------

@Stack, A duplicate of HBASE-6518, or the other way around?

@Ted, jvm will check in.length() > i+1, at first, only if it is true, then it will check in.charAt(i+1)
so there is no ArrayIndexOutOfBoundsException issue actually. Without the patch, the new unit test should be ok.

                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475271#comment-13475271 ] 

Ted Yu commented on HBASE-3444:
-------------------------------

Looks like HBASE-6518 has fixed this issue in trunk.

Thanks Jimmy.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474441#comment-13474441 ] 

Hadoop QA commented on HBASE-3444:
----------------------------------

{color:red}-1 overall{color}.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12548782/3444.txt
  against trunk revision .

    {color:green}+1 @author{color}.  The patch does not contain any @author tags.

    {color:green}+1 tests included{color}.  The patch appears to include 3 new or modified tests.

    {color:green}+1 hadoop2.0{color}.  The patch compiles against the hadoop 2.0 profile.

    {color:red}-1 javadoc{color}.  The javadoc tool appears to have generated 81 warning messages.

    {color:green}+1 javac{color}.  The applied patch does not increase the total number of javac compiler warnings.

    {color:red}-1 findbugs{color}.  The patch appears to introduce 5 new Findbugs (version 1.3.9) warnings.

    {color:green}+1 release audit{color}.  The applied patch does not increase the total number of release audit warnings.

     {color:red}-1 core tests{color}.  The patch failed these unit tests:
                       org.apache.hadoop.hbase.master.TestSplitLogManager
                  org.apache.hadoop.hbase.catalog.TestMetaReaderEditor

Test results: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//testReport/
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-hadoop2-compat.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-hadoop1-compat.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-common.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-server.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-hadoop-compat.html
Console output: https://builds.apache.org/job/PreCommit-HBASE-Build/3034//console

This message is automatically generated.
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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

[jira] [Commented] (HBASE-3444) Bytes.toBytesBinary and Bytes.toStringBinary() should be reversible

Posted by "Ted Yu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475197#comment-13475197 ] 

Ted Yu commented on HBASE-3444:
-------------------------------

@Jimmy:
The patch modifies the above line of code:
{code}
-      if (ch == '\\' && in.length() > i+1 && in.charAt(i+1) == 'x') {
{code}
Can you take a second look ?
                
> Bytes.toBytesBinary and Bytes.toStringBinary()  should be reversible
> --------------------------------------------------------------------
>
>                 Key: HBASE-3444
>                 URL: https://issues.apache.org/jira/browse/HBASE-3444
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Prakash Khemani
>            Assignee: Ken Dallmeyer
>            Priority: Minor
>             Fix For: 0.96.0
>
>         Attachments: 3444.txt
>
>
> Bytes.toStringBinary() doesn't escape \.
> Otherwise the transformation isn't reversible
> byte[] a = {'\', 'x' , '0', '0'}
> Bytes.toBytesBinary(Bytes.toStringBinary(a)) won't be equal to a

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