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] A RI's bug of SerialBlob.getBytes(long position, int length)?
Date Tue, 12 Dec 2006 14:07:07 GMT
On 12/12/06, Oleg Khaschansky <oleg.v.khaschansky@gmail.com> wrote:

> > works fine on RI, which seems to be illogical.
> I mean I think that
> byte [] data = serialBlob.getBytes(2, 10);
> also should not throw any exceptions and should return 7 bytes of data.


+1. The spec explicitly points out "Note that if the given number of bytes
to be copied is larger than the length of this SerialBlob object's array of
bytes, the given number will be shortened to the array's length."



> On 12/12/06, Oleg Khaschansky <oleg.v.khaschansky@gmail.com> wrote:
> > It looks like it is a bug of RI.
> >
> > Also, I changed one line to:
> >        byte [] data = serialBlob.getBytes(2, 10);
> > and got another exception on RI:
> > Exception in thread "Main Thread"
> java.lang.ArrayIndexOutOfBoundsException: 8
> >
> > At the same time
> >        byte [] data = serialBlob.getBytes(1, 10);
> > works fine on RI, which seems to be illogical.
> >
> > On 12/11/06, Andrew Zhang <zhanghuangzhu@gmail.com> wrote:
> > > Hi folks,
> > > SerialBlob spec points out that getBytes(long position, int length)
> should
> > > throw SerialException if the given starting position is out of bounds.
> But
> > > RI also throws SerialException when the position is in the bound of
> the
> > > array in some other cases. Consider following code:
> > >
> > > public void testGetBytesJI1() throws Exception {
> > >         byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
> > >         SerialBlob serialBlob = new SerialBlob(buf);
> > >         byte [] data = serialBlob.getBytes(2, 1);
> > >         assertEquals(1, data.length);
> > >         assertEquals(2, data[0]);
> > >    }
> > >
> > > IMO, the starting position 2 and the length 1 are both valid. But RI
> throws
> > > SerialException with message "Invalid arguments: position cannot be
> less
> > > that 1". Is it a bug of RI? Or did I missing something? Any
> suggestions?
> > > Thanks in advance!
> > >
> > > --
> > > Best regards,
> > > Andrew Zhang
> > >
> > >
> >
>



-- 
Best regards,
Andrew Zhang

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