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] SerialClob.setString doesn't set correct value, RI's bug?!
Date Fri, 09 Mar 2007 01:56:31 GMT
Hi,

Noticed that RI doesn't set correct value with SerialClob.setString(long,
String, int, int)[1]. Consider following code:
 public void testSetStringJLStringII() throws Exception {
        String s = "hello";
        char[] buf = s.toCharArray();
        SerialClob serialClob = new SerialClob(buf);

        serialClob.setString(1, "olleh", 0, 5);
        String sub = serialClob.getSubString(1, 5);
        assertEquals("olleh", sub);

        serialClob.setString(2, "mmnn",1, 2);
        sub = serialClob.getSubString(1, 5);
        assertEquals("omneh", sub); // RI fails here
}

After setting, RI fails the test with value "onneh". The test is
straightforward. Do I miss something? Or it's RI's bug?
Thanks!


[1]
Following is quoted from java spec:
public int setString(long pos, String str, int offset, int length) throws
SerialException
Writes len characters of str, starting at character offset, to the CLOB
value that this Clob represents.

Parameters -
pos - the position at which to start writing to the CLOB value that this
SerialClob object represents; the first position is 1; must not be less than
1 nor greater than the length of this SerialClob object
str - the string to be written to the CLOB value that this Clob object
represents
offset - the offset into str to start reading the characters to be written
length - the number of characters to be written


-- 
Best regards,
Andrew Zhang

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