Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 10588 invoked from network); 12 Dec 2006 22:35:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Dec 2006 22:35:46 -0000 Received: (qmail 7971 invoked by uid 500); 12 Dec 2006 22:35:51 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 7869 invoked by uid 500); 12 Dec 2006 22:35:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 7858 invoked by uid 99); 12 Dec 2006 22:35:50 -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 14:35:50 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2006 14:35:42 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5EDA071413F for ; Tue, 12 Dec 2006 14:35:22 -0800 (PST) Message-ID: <28541737.1165962922385.JavaMail.jira@brutus> Date: Tue, 12 Dec 2006 14:35:22 -0800 (PST) From: "Henri Yandell (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Updated: (LANG-299) Bug in method appendFixedWidthPadRight of class StrBuilder causes an ArrayIndexOutOfBoundsException In-Reply-To: <10496419.1165838421075.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/LANG-299?page=all ] Henri Yandell updated LANG-299: ------------------------------- Attachment: LANG-299.patch Unit test created and fix applied. > Bug in method appendFixedWidthPadRight of class StrBuilder causes an ArrayIndexOutOfBoundsException > --------------------------------------------------------------------------------------------------- > > Key: LANG-299 > URL: http://issues.apache.org/jira/browse/LANG-299 > Project: Commons Lang > Issue Type: Bug > Affects Versions: 2.2 > Reporter: Francisco Benavent > Attachments: LANG-299.patch > > > There's a bug in method appendFixedWidthPadRight of class StrBuilder: > public StrBuilder appendFixedWidthPadRight(Object obj, int width, char padChar) { > if (width > 0) { > ensureCapacity(size + width); > String str = (obj == null ? getNullText() : obj.toString()); > int strLen = str.length(); > if (strLen >= width) { > ==> str.getChars(0, strLen, buffer, size); <==== BUG: it should be str.getChars(0, width, buffer, size); > } else { > int padLen = width - strLen; > str.getChars(0, strLen, buffer, size); > for (int i = 0; i < padLen; i++) { > buffer[size + strLen + i] = padChar; > } > } > size += width; > } > return this; > } > This is causing an ArrayIndexOutOfBoundsException, so this method is unusable when strLen > width. > It's counterpart method appendFixedWidthPadLeft seems to be ok. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org