You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Chad Whipkey (JIRA)" <ji...@apache.org> on 2008/05/28 00:36:59 UTC

[jira] Created: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

Text.find incorrectly searches beyond the end of the buffer
-----------------------------------------------------------

                 Key: HADOOP-3454
                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
             Project: Hadoop Core
          Issue Type: Bug
    Affects Versions: 0.17.0
            Reporter: Chad Whipkey



Text.find() does not pay attention to the length field.  So, this code:

{panel}
    public void testTextFind()
    {
        Text t = new Text("FIND AN I");
        t.set(new byte[] { (byte) 'F' });

        assert t.getLength() == 1 : "Length should be 1";
        assert t.find( "F") == 0 : "Found F at " + t.find("F");
        assert t.find( "I") == -1 : "Found I at " + t.find("I");
    }
{panel}

incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.

I think to fix this it is enough to change this line in Text.find:

ByteBuffer src = ByteBuffer.wrap(this.bytes);

to 

ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chad Whipkey updated HADOOP-3454:
---------------------------------

    Attachment: HADOOP-3454.patch

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>         Attachments: HADOOP-3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Commented: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Hudson commented on HADOOP-3454:
--------------------------------

Integrated in Hadoop-trunk #511 (See [http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/511/])

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>            Assignee: Chad Whipkey
>             Fix For: 0.18.0
>
>         Attachments: HADOOP-3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chad Whipkey updated HADOOP-3454:
---------------------------------

    Description: 
Text.find() does not pay attention to the length field.  So, this code:

{code}
    public void testTextFind()
    {
        Text t = new Text("FIND AN I");
        t.set(new byte[] { (byte) 'F' });

        assert t.getLength() == 1 : "Length should be 1";
        assert t.find( "F") == 0 : "Found F at " + t.find("F");
        assert t.find( "I") == -1 : "Found I at " + t.find("I");
    }
{code}

incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.

I think to fix this it is enough to change this line in Text.find:

ByteBuffer src = ByteBuffer.wrap(this.bytes);

to 

ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

  was:

Text.find() does not pay attention to the length field.  So, this code:

{panel}
    public void testTextFind()
    {
        Text t = new Text("FIND AN I");
        t.set(new byte[] { (byte) 'F' });

        assert t.getLength() == 1 : "Length should be 1";
        assert t.find( "F") == 0 : "Found F at " + t.find("F");
        assert t.find( "I") == -1 : "Found I at " + t.find("I");
    }
{panel}

incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.

I think to fix this it is enough to change this line in Text.find:

ByteBuffer src = ByteBuffer.wrap(this.bytes);

to 

ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);


> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Commented: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-3454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600298#action_12600298 ] 

Doug Cutting commented on HADOOP-3454:
--------------------------------------

Can you please attach a patch file that fixes this and adds a unit test illustrating the problem?  Thanks!

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chad Whipkey updated HADOOP-3454:
---------------------------------

    Attachment:     (was: patch_haddop_3454.patch)

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>         Attachments: HADOOP-3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chad Whipkey updated HADOOP-3454:
---------------------------------

    Attachment: patch_haddop_3454.patch

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>         Attachments: patch_haddop_3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chad Whipkey updated HADOOP-3454:
---------------------------------

    Status: Patch Available  (was: Open)

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>         Attachments: HADOOP-3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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


[jira] Updated: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer

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

Chris Douglas updated HADOOP-3454:
----------------------------------

       Resolution: Fixed
    Fix Version/s: 0.18.0
         Assignee: Chad Whipkey
     Hadoop Flags: [Reviewed]
           Status: Resolved  (was: Patch Available)

+1 Patch looks good.

I just committed this. Thanks, Chad

> Text.find incorrectly searches beyond the end of the buffer
> -----------------------------------------------------------
>
>                 Key: HADOOP-3454
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3454
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Chad Whipkey
>            Assignee: Chad Whipkey
>             Fix For: 0.18.0
>
>         Attachments: HADOOP-3454.patch
>
>
> Text.find() does not pay attention to the length field.  So, this code:
> {code}
>     public void testTextFind()
>     {
>         Text t = new Text("FIND AN I");
>         t.set(new byte[] { (byte) 'F' });
>         assert t.getLength() == 1 : "Length should be 1";
>         assert t.find( "F") == 0 : "Found F at " + t.find("F");
>         assert t.find( "I") == -1 : "Found I at " + t.find("I");
>     }
> {code}
> incorrectly throws an assertion because it finds the I at position 1, even though the Text is only one byte long.
> I think to fix this it is enough to change this line in Text.find:
> ByteBuffer src = ByteBuffer.wrap(this.bytes);
> to 
> ByteBuffer src = ByteBuffer.wrap(this.bytes,0,this.length);

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