[ https://issues.apache.org/jira/browse/TEXT-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16223432#comment-16223432 ]
ASF GitHub Bot commented on TEXT-106: ------------------------------------- GitHub user kinow opened a pull request: https://github.com/apache/commons-text/pull/73 Exception thrown in ExtendedMessageFormat using quotes with custom registry Created this pull request from the patch provided by Benoît Moreau in [TEXT-106](https://issues.apache.org/jira/browse/TEXT-106). Thanks for your contribution Benoît! Cheers Bruno You can merge this pull request into a Git repository by running: $ git pull https://github.com/kinow/commons-text TEXT-106 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-text/pull/73.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #73 ---- commit 1596501e610bca7955969bb94fe6c6bad397e361 Author: Bruno P. Kinoshita <brunodepau...@yahoo.com.br> Date: 2017-10-28T11:28:04Z TEXT-106: Exception thrown in ExtendedMessageFormat using quotes with custom registry Applying patch provided by Benoît Moreau (thanks!). ---- > Exception thrown in ExtendedMessageFormat using quotes with custom registry > --------------------------------------------------------------------------- > > Key: TEXT-106 > URL: https://issues.apache.org/jira/browse/TEXT-106 > Project: Commons Text > Issue Type: Bug > Affects Versions: 1.1 > Reporter: Benoît Moreau > Assignee: Bruno P. Kinoshita > Attachments: ExtendedMessageFormat.java.patch, > ExtendedMessageFormatTest.java.patch > > > An exception is thrown when a quote is used just before end brace of format > element definition when a custom registry is used. > This exception is not thrown when a blank space is added before the end brace. > {code:java} > public static void main(String[] args) > { > String pattern = "TEST: {0,choice,0#0|0<'1'}"; > String patternWorkaround = "TEST: {0,choice,0#0|0<'1' }"; // a space > after quote > // Works fine > MessageFormat format0 = new MessageFormat(pattern); > System.out.println(format0.format(new Integer[] { 0 })); // "TEST: 0" > System.out.println(format0.format(new Integer[] { 1 })); // "TEST: 1" > // Works fine > ExtendedMessageFormat format1 = new ExtendedMessageFormat(pattern); > System.out.println(format1.format(new Integer[] { 0 })); // "TEST: 0" > System.out.println(format1.format(new Integer[] { 1 })); // "TEST: 1" > // Works fine > ExtendedMessageFormat format2 = new > ExtendedMessageFormat(patternWorkaround, new HashMap<String, > FormatFactory>()); > System.out.println(format2.format(new Integer[] { 0 })); // "TEST: 0" > System.out.println(format2.format(new Integer[] { 1 })); // "TEST: 1 " > // Doesn't work > ExtendedMessageFormat format3 = new ExtendedMessageFormat(pattern, new > HashMap<String, FormatFactory>()); > System.out.println(format3.format(new Integer[] { 0 })); // Exception > in thread "main" java.lang.IllegalArgumentException: Unterminated format > element at position 9 > System.out.println(format3.format(new Integer[] { 1 })); > } > {code} > Expected behavior: This exception should not be thrown. -- This message was sent by Atlassian JIRA (v6.4.14#64029)