FYI. Harmony-2335, 2836 were filed for SerialBlob.setBytes methods.
On 12/19/06, Andrew Zhang <[EMAIL PROTECTED]> wrote:
Hi guys,
Any other opnions? If no one objects, I'll file a non-bug-difference-from
RI JIRA for this issue. Thanks!
On 12/18/06, Andrew Zhang <[EMAIL PROTECTED]> wrote:
>
> Hi guys,
>
> It's SerialBlob again. It's the third time to ask similar question about
> SerialBlob class. :)
> Let's take a look at the spec of setBytes(long pos,byte [] bytes, int
> offset, int length). Throws SerialException - if there is an error
> accessing the BLOB 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
> SerialBlob length; or the combined values of the length and offset is
> greater than the Blob buffer
>
> As my understanding, the tortuous words shows that setBytes should throw
> SerialException if there's any array index outbound. But following code
> shows that RI's behaviour looks weird:
> public void testSetBytes() throws Exception {
> byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
> byte[] theBytes = { 9, 9, 9 };
> SerialBlob serialBlob = new SerialBlob(buf);
> serialBlob.setBytes (7, theBytes); //
> ArrayIndexOutOfBoundsException
> serialBlob.setBytes(7, theBytes, 0, 3); //
> ArrayIndexOutOfBoundsException
> serialBlob.setBytes(7, theBytes, 0, 10); // SerialException
> }
> Let's look at the spec again, what does "the combined values of the
> length and offset is greater than the Blob buffer " mean? The previous
> sentence already says "if number of bytes to be written (length) is greater
> than the SerialBlob length(Blob buffer)".
>
> The spec of another similar method setBytes(long pos, byte[] bytes)
> looks more interesting:
> SerialException - if there is an error accessing the BLOB value; or if
> an invalid position is set; if an invalid offset value is set
> But who can tell me what does "if an invalid offset value is set" mean?
> :-)
>
> The SerialBlob class looks scary to me. What shall we do for setBytes?
> Follow RI or always throw SerialException for invalid array index?
> Personally I prefer to the latter one, and if it breaks any existing
> application or fails TCK tests later, then let's fix it. Any
> suggestions/comments? Thanks in advance!
>
>
> --
> Best regards,
> Andrew Zhang
>
--
Best regards,
Andrew Zhang
--
Best regards,
Andrew Zhang