[ 
https://issues.apache.org/jira/browse/LOG4J2-2850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17230711#comment-17230711
 ] 

ASF subversion and git services commented on LOG4J2-2850:
---------------------------------------------------------

Commit b6eac5f4ecc742883b2f68392369344ed217ccf9 in logging-log4j2's branch 
refs/heads/master from Sandeep Barnwal
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=b6eac5f ]

LOG4J2-2850 : LocalizedMessageFactory creates new message with baseName as 
messagePattern

Added test cases


> LocalizedMessageFactory creates new message with baseName as messagePattern
> ---------------------------------------------------------------------------
>
>                 Key: LOG4J2-2850
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2850
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.13.3
>            Reporter: Diego Villablanca
>            Priority: Trivial
>              Labels: easyfix
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> When I instantiate LocalizedMessageFactory with the String baseName 
> constructor and then I create a new LocalizedMessage by the method _public 
> Message newMessage(final String key)_, it instantiates the message with the 
> constructor that use String messagePattern and String key, using the resource 
> bundle baseName as messagePattern, and the key as an argument of the pattern.
> {code:java}
> /**
> * @since 2.8
> */
> @Override
> public Message newMessage(final String key) {
>     if (resourceBundle == null) {
>         return new LocalizedMessage(baseName,  key);
>     }
>     return new LocalizedMessage(resourceBundle, key);
> }{code}
> The constructor of LocalizedMessage used is:
> {code:java}
> public LocalizedMessage(final String messagePattern, final Object arg) {
>     this((ResourceBundle) null, (Locale) null, messagePattern, new Object[] 
> {arg});
> }
> {code}
>  The Factory should use this constructor: 
> {code:java}
> public LocalizedMessage(final String baseName, final String key, final Object 
> arg) {
>     this(baseName, (Locale) null, key, new Object[] {arg});
> }{code}
>   The fix should be: 
> {code:java}
> /**
>  * @since 2.8
>  */
> @Override
> public Message newMessage(final String key) {
>     if (resourceBundle == null) {
>         return new LocalizedMessage(baseName, key, null);
>     }
>     return new LocalizedMessage(resourceBundle, key);
> }
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to