You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2010/02/25 22:06:27 UTC

[jira] Updated: (LANG-509) OutOfMemory Error caused by ExtendedMessageFormat

     [ https://issues.apache.org/jira/browse/LANG-509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton updated LANG-509:
---------------------------------

    Fix Version/s:     (was: 3.0)
                   2.5

> OutOfMemory Error caused by ExtendedMessageFormat
> -------------------------------------------------
>
>                 Key: LANG-509
>                 URL: https://issues.apache.org/jira/browse/LANG-509
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>    Affects Versions: 2.4
>         Environment: Windows XP, Tomcat 5.5.27, Sun JDK 1.6.0_13
>            Reporter: Kai Hackemesser
>             Fix For: 2.5
>
>
> 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.