harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Zakharov" <alexei.zakha...@gmail.com>
Subject Re: [classlib][sql] Compatibility issue of SerialBlob.truncate(long length)
Date Mon, 01 Jan 2007 10:31:09 GMT
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.
Now we've got incompatibility almost in every SerialBlob method, right?

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

Mime
View raw message