hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chad Whipkey (JIRA)" <j...@apache.org>
Subject [jira] Created: (HADOOP-3454) Text.find incorrectly searches beyond the end of the buffer
Date Tue, 27 May 2008 22:36:59 GMT
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:

    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");

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


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.

View raw message