Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 83918 invoked from network); 12 Dec 2006 14:07:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Dec 2006 14:07:38 -0000 Received: (qmail 19691 invoked by uid 500); 12 Dec 2006 14:07:45 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 19311 invoked by uid 500); 12 Dec 2006 14:07:43 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 19302 invoked by uid 99); 12 Dec 2006 14:07:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2006 06:07:43 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of zhanghuangzhu@gmail.com designates 66.249.92.175 as permitted sender) Received: from [66.249.92.175] (HELO ug-out-1314.google.com) (66.249.92.175) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2006 06:07:32 -0800 Received: by ug-out-1314.google.com with SMTP id z36so1638151uge for ; Tue, 12 Dec 2006 06:07:07 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=K1hdCEx+Fiw/YhVKiEadrRY8NyWilDvklpgl1ScfuwzH9Jnt5mr5fVAlyNEzrz20gFxsyO99yTs1WAwHl0ck3lThIs9fL+0ZkczvimzJxYmkpIwiFMyiyMBPCdYjADZJasSXZtC5xlU8qQAQzAumFIaM0OZ2ByMV2YIbYU1g9XA= Received: by 10.82.113.6 with SMTP id l6mr715523buc.1165932427079; Tue, 12 Dec 2006 06:07:07 -0800 (PST) Received: by 10.82.113.12 with HTTP; Tue, 12 Dec 2006 06:07:07 -0800 (PST) Message-ID: <4d0b24970612120607q6095198fn79f631bebf09cfb3@mail.gmail.com> Date: Tue, 12 Dec 2006 22:07:07 +0800 From: "Andrew Zhang" To: dev@harmony.apache.org Subject: Re: [classlib][sql] A RI's bug of SerialBlob.getBytes(long position, int length)? In-Reply-To: <26c14c2a0612120600m1d30ffcehdf14e31c2201abdd@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_89734_1359753.1165932427047" References: <4d0b24970612110347y65fa62f3n51b13eca0c4bd3d1@mail.gmail.com> <26c14c2a0612120555s51c8a910hb75cfa6e5a7390af@mail.gmail.com> <26c14c2a0612120600m1d30ffcehdf14e31c2201abdd@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_89734_1359753.1165932427047 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/12/06, Oleg Khaschansky 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 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 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 ------=_Part_89734_1359753.1165932427047--