harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject [classlib][sql] RI's bug of SerialBlob.position(byte[] pattern, long start)?
Date Tue, 12 Dec 2006 08:21:53 GMT
Hi folks,

I found that RI's behaviour of SerialBlob.postion(byte[] pattern, long
start) looks strange. Consider following code:

    private void testPosition_BytePattern()
            throws SerialException, SQLException {

        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob blob = new SerialBlob(buf);


        byte[]  pattern = new byte[] { 2, 4 };
        long pos = blob.position(pattern, 1);
        // FIXME: RI's bug?
        assertEquals(-1, pos);

    }

It tries to find pattern "2,4" from blob with data "1,2,3,4,5,6,7,8". RI
returns 3 instead of -1. Spec says the method "returns the position in this
SerialBlob object where the given pattern of bytes begins, starting the
search at the specified position. "and "position numbering for the return
value starts at 1".

Did I misunderstand the spec? Or it's a bug of RI? Thanks!
-- 
Best regards,
Andrew Zhang

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message