The main JavaDoc description seems quite clear to me:
"If this SerialBlob is instantiated with a byte array, a SerialException
is thrown."
So I say throw the SerialException.
Regards,
Tim
Andrew Zhang wrote:
> Hi guys,
>
> sorry, SerialBlob compatibility problem again. It's the last unimplemented
> method of SerialBlob, setBinaryStream(long pos). The spec says "throws
> SerialException - if the SerialBlob in not instantiated with a Blob object
> that supports setBinaryStream()". What should happen if the SerialBlob is
> instantiated with a byte buffer? As my understanding, it should throw
> SerialException, but I feel the spec is a little ambiguous, is it? I need
> native speakers' help. :-) Anyway, I think throws SerialException sounds
> reasonable to me if it's instantiated with a byte buffer. But RI throws
> NullPointerException instead. Following test shows the problem:
> public void testSetBinaryStreamJ() throws Exception {
> byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
> SerialBlob serialBlob = new SerialBlob(buf);
> serialBlob.setBinaryStream(1);
> }
> Shall we follow RI or throw SerialException? Thanks!
>