Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 33926 invoked from network); 8 Jun 2009 07:00:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jun 2009 07:00:28 -0000 Received: (qmail 22689 invoked by uid 500); 8 Jun 2009 07:00:39 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 22581 invoked by uid 500); 8 Jun 2009 07:00:39 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 22571 invoked by uid 99); 8 Jun 2009 07:00:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2009 07:00:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2009 07:00:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 4B738234C056 for ; Mon, 8 Jun 2009 00:00:12 -0700 (PDT) Message-ID: <1485108379.1244444407355.JavaMail.jira@brutus> Date: Mon, 8 Jun 2009 00:00:07 -0700 (PDT) From: "Kai Hackemesser (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (LANG-509) OutOfMemory Error caused by ExtendedMessageFormat In-Reply-To: <802346365.1244444287726.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kai Hackemesser updated LANG-509: --------------------------------- Description: It is possible to let ExtendedMessageFormat cause an OutOfMemory Error (Java heap space) - no matter how large you define the memory, because the code produces an endless loop that extends a StringBuffer ad infinitum. Code to reproduce: instantiate an ExtendedMessageFormat object using the constructor public ExtendedMessageFormat(String pattern, Locale locale, Map registry) locale and registry (not null) don't matter actually, but pattern as String looks like this: {{The field ''{0}'' must be completed}} notice the doubled single quotes. The constructor then executes applyPattern(pattern) In applyPattern, line 158 (that is inside the loop over the pattern length) {{appendQuotedString(pattern, pos, stripCustom, true);}} is called, it is the last statement for that case in the loop. In appendQuotedString, line 422 the quote character gets appended to the return StringBuffer, then return. The problem in fact is, that the pointer (ParsePosition pos) isn't updated and after return the procedure will check the same character again and again and again. Primitive workaround: no use of single quotes in messages as input of ExtendedMessageFormat. was: It is possible to let ExtendedMessageFormat cause an OutOfMemory Error (Java heap space) - no matter how large you define the memory, because the code produces an endless loop that extends a StringBuffer ad infinitum. Code to reproduce: instantiate an ExtendedMessageFormat object using the constructor public ExtendedMessageFormat(String pattern, Locale locale, Map registry) locale and registry (not null) dosen't matter actually, but pattern as String looks like this: {{The field ''{0}'' must be completed}} notice the doubled single quotes. The constructor then executes applyPattern(pattern) In applyPattern, line 158 (that is inside the loop over the pattern length) {{appendQuotedString(pattern, pos, stripCustom, true);}} is called, it is the last statement for that case in the loop. In appendQuotedString, line 422 the quote character gets appended to the return StringBuffer, then return. The problem in fact is, that the pointer (ParsePosition pos) isn't updated and after return the procedure will check the same character again and again and again. Primitive workaround: no use of single quotes in messages as input of ExtendedMessageFormat. > OutOfMemory Error caused by ExtendedMessageFormat > ------------------------------------------------- > > Key: LANG-509 > URL: https://issues.apache.org/jira/browse/LANG-509 > Project: Commons Lang > Issue Type: Bug > Affects Versions: 2.4 > Environment: Windows XP, Tomcat 5.5.27, Sun JDK 1.6.0_13 > Reporter: Kai Hackemesser > > It is possible to let ExtendedMessageFormat cause an OutOfMemory Error (Java heap space) - no matter how large you define the memory, because the code produces an endless loop that extends a StringBuffer ad infinitum. > Code to reproduce: > instantiate an ExtendedMessageFormat object using the constructor > public ExtendedMessageFormat(String pattern, Locale locale, Map registry) > locale and registry (not null) don't matter actually, but pattern as String looks like this: > {{The field ''{0}'' must be completed}} > notice the doubled single quotes. > The constructor then executes applyPattern(pattern) > In applyPattern, line 158 (that is inside the loop over the pattern length) {{appendQuotedString(pattern, pos, stripCustom, true);}} is called, it is the last statement for that case in the loop. > In appendQuotedString, line 422 the quote character gets appended to the return StringBuffer, then return. The problem in fact is, that the pointer (ParsePosition pos) isn't updated and after return the procedure will check the same character again and again and again. > Primitive workaround: no use of single quotes in messages as input of ExtendedMessageFormat. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.