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/07 03:51:27 UTC

[classlib][sql] Non-bug difference of SerialClob.setString(long, String)?

Hi guys,

As spec says, SerialClob.setString(long, String) throws SerialException - if
there is an error accessing the CLOB value; if an invalid position is set;
if an invalid offset value is set; if number of bytes to be written is
greater than the SerialClob length; or the combined values of the length and
offset is greater than the Clob buffer. But following code throws
ArrayIndexOutOfBoundException instead.
public void test() {
        String s = "hello";
        char[] buf = s.toCharArray();
        SerialClob serialClob = new SerialClob(buf);
        try {
            serialClob.setString(2, "hello");
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
}

Shall we follow RI or spec for this case?
We encounter many similar non-bug differences in SerialBlob, and IMHO, we'd
better follow spec and not copy RI's bug.
What's your opnion? Thanks!

-- 
Best regards,
Andrew Zhang

Re: [classlib][sql] Non-bug difference of SerialClob.setString(long, String)?

Posted by Richard Liang <ri...@gmail.com>.
On 3/7/07, Andrew Zhang <zh...@gmail.com> wrote:
> Hi guys,
>
> As spec says, SerialClob.setString(long, String) throws SerialException - if
> there is an error accessing the CLOB value; if an invalid position is set;
> if an invalid offset value is set; if number of bytes to be written is
> greater than the SerialClob length; or the combined values of the length and
> offset is greater than the Clob buffer. But following code throws
> ArrayIndexOutOfBoundException instead.
> public void test() {
>         String s = "hello";
>         char[] buf = s.toCharArray();
>         SerialClob serialClob = new SerialClob(buf);
>         try {
>             serialClob.setString(2, "hello");
>             fail("should throw SerialException");
>         } catch (SerialException e) {
>             // expected
>         }
> }
>
> Shall we follow RI or spec for this case?
> We encounter many similar non-bug differences in SerialBlob, and IMHO, we'd
> better follow spec and not copy RI's bug.
> What's your opnion? Thanks!

Yes, we shall follow Spec in this situation.

>
> --
> Best regards,
> Andrew Zhang
>


-- 
Richard Liang
China Development Lab, IBM

Re: [classlib][sql] Non-bug difference of SerialClob.setString(long, String)?

Posted by Andrew Zhang <zh...@gmail.com>.
If no one objects, I'll file a JIRA issue to record it as non bug difference
from RI.

On 3/7/07, Andrew Zhang <zh...@gmail.com> wrote:
>
> Hi guys,
>
> As spec says, SerialClob.setString(long, String) throws SerialException -
> if there is an error accessing the CLOB value; if an invalid position is
> set; if an invalid offset value is set; if number of bytes to be written is
> greater than the SerialClob length; or the combined values of the length and
> offset is greater than the Clob buffer. But following code throws
> ArrayIndexOutOfBoundException instead.
> public void test() {
>         String s = "hello";
>         char[] buf = s.toCharArray();
>         SerialClob serialClob = new SerialClob(buf);
>         try {
>             serialClob.setString(2, "hello");
>             fail("should throw SerialException");
>         } catch (SerialException e) {
>             // expected
>         }
> }
>
> Shall we follow RI or spec for this case?
> We encounter many similar non-bug differences in SerialBlob, and IMHO,
> we'd better follow spec and not copy RI's bug.
> What's your opnion? Thanks!
>
> --
> Best regards,
> Andrew Zhang
>



-- 
Best regards,
Andrew Zhang