harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib][sql] Compatibility issue of SerialBlob.truncate(long length)
Date Mon, 01 Jan 2007 13:05:46 GMT
On 1/1/07, Alexei Zakharov <alexei.zakharov@gmail.com> wrote:

> Hi Andrew,
>
> IMHO if exception is thrown then the object is in inconsistent state
> anyway. So it does not really matter what the length() method returns.
> However, negative length also doesn't make sense to me. So here is my
> +1 for not touching the length.


As my understanding, such exception is a way to tell user that the parameter
is invalid. But the object can still be used later. Therefore, I'd like not
to change the length value here.



> Now we've got incompatibility almost in every SerialBlob method, right?


yes. And maybe one more in setBinaryStream method. :)



> Regards,
>
> 2007/1/1, Andrew Zhang <zhanghuangzhu@gmail.com>:
> > Hi folks,
> >
> > I encountered another compatibility issue (the fourth one?) of
> SerialBlob
> > class. It's about truncate(long length) method. Spec says "Throws
> > SerialException - if there is an error accessing the Blob value; or the
> > length to truncate is greater that the SerialBlob length". But it
> doesn't
> > mention what happens if the length is negative. I tried following test
> code:
> >
> > public void testTruncateJ() throws Exception {
> >         byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
> >         SerialBlob serialBlob1 = new SerialBlob(buf);
> >         try {
> >             serialBlob1.truncate(-1);
> >         } catch (SerialException e) {
> >             System.out.println(e.getMessage());
> >         }
> >         System.out.println(serialBlob1.length());
> > }
> > The RI output is:
> > Invalid arguments: position cannot be less that 1
> > -1
> > The first output SerialException is quite reasonable and the message
> also
> > sounds good. But the length is then changed to -1. IMO, if truncate
> method
> > regards -1 as an illegal argument, it should not change the length value
> > anyway. So I suggest that Harmony throws SerialException as RI and
> doesn't
> > change the length value (any internal data of serial blob). What's your
> > opnion? Thanks in adavance!
> >
> > --
> > Best regards,
> > Andrew Zhang
> >
> >
>
>
> --
> Alexei Zakharov,
> Intel ESSD
>



-- 
Best regards,
Andrew Zhang

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