You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Andrew Zhang <zh...@gmail.com> on 2007/03/09 02:56:31 UTC

[classlib][sql] SerialClob.setString doesn't set correct value, RI's bug?!

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

Re: [classlib][sql] SerialClob.setString doesn't set correct value, RI's bug?!

Posted by Alexei Zakharov <al...@gmail.com>.
Hi Andrew,

Sorry for the late reply. I've run a couple of tests for SerialClob.
IMO it is obvious that RI has bugs in either setString() or
getSubString(). So I am +1 for following the spec.

Thanks,

2007/3/12, Andrew Zhang <zh...@gmail.com>:
> On 3/9/07, Andrew Zhang <zh...@gmail.com> wrote:
> >
> > 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!
> >
>
> If no one objects, I'll consider it as a bug of RI, and won't follow RI for
> this case.
>
>
> >
> > [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


-- 
Alexei Zakharov,
Intel ESSD

Re: [classlib][sql] SerialClob.setString doesn't set correct value, RI's bug?!

Posted by Andrew Zhang <zh...@gmail.com>.
On 3/9/07, Andrew Zhang <zh...@gmail.com> wrote:
>
> 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!
>

If no one objects, I'll consider it as a bug of RI, and won't follow RI for
this case.


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



-- 
Best regards,
Andrew Zhang