commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (LANG-948) Exception while using ExtendedMessageFormat and escaping braces
Date Sun, 13 Apr 2014 14:07:15 GMT


ASF GitHub Bot commented on LANG-948:

GitHub user Andrey-Khobnya opened a pull request:

    Fix LANG-948

    Hi all!
    This is fix for bug LANG-948.
    Changes with explanations:
    1) Method ```ExtendedMessageFormat.appendQuotedString()``` returned when finds first quote
character. This is obviously wrong because quoted string start with quote character and method
must consume whole quoted string. I added handling of first quote character at the beginning
of method. Also, it doesn't make sense to handle escaped quotes because ```super.applyPattern(stripCustom.toString())```
will called below in ```applyPattern()```. Thus, last argument should be ```false``` when
calling ```appendQuotedString()```.
    2) Quoted string must start with quote character in ```appendQuotedString()```. And at
this moment method is used this way. I added assertion to check and document this.
    3) Thus, method ```appendQuotedString()``` is called with last argument always ```false```.
It doesn't make sense to handle escaped quotes in ```appendQuotedString()``` because they
will be handled in ```super.applyPattern()```. Thus, I deleted this parameter and code for
handling escaped quotes.

You can merge this pull request into a Git repository by running:

    $ git pull fix-948

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #19
commit 86e64df6ce7e879c5f608aa7276c251377574f56
Author: Andrey Khobnya <>
Date:   2014-04-13T12:36:07Z

    Fix LANG-948

commit 0f9222d5cccbe27fbda5ab9b97b231162e4b089b
Author: Andrey Khobnya <>
Date:   2014-04-13T12:42:02Z

    Add assertion in ExtendedMessageFormat.appendQuotedString() to check and
    document proper usage

commit 4d372f3ce65087c8863332c74c2563a165d7aa12
Author: Andrey Khobnya <>
Date:   2014-04-13T12:49:28Z

    It doesn't make sense to handle escaped quotes in
    ExtendedMessageFormat.appendQuotedString() because they will be handled
    in super.applyPattern()


> Exception while using ExtendedMessageFormat and escaping braces
> ---------------------------------------------------------------
>                 Key: LANG-948
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>    Affects Versions: 3.2, 3.2.1
>            Reporter: Nicolò Chieffo
>             Fix For: Patch Needed
>         Attachments:,
> Exception while trying to format a string containing escaped braces
> {code}
> Exception in thread "main" java.lang.IllegalArgumentException: Invalid format argument
index at position 7: }
> 	at org.apache.commons.lang3.text.ExtendedMessageFormat.readArgumentIndex(
> 	at org.apache.commons.lang3.text.ExtendedMessageFormat.applyPattern(
> 	at org.apache.commons.lang3.text.ExtendedMessageFormat.<init>(
> 	at org.apache.commons.lang3.text.ExtendedMessageFormat.<init>(
> 	at test.TestExtendedMessageFormat.main(
> {code}
> I will attach a source

This message was sent by Atlassian JIRA

View raw message