[
https://issues.apache.org/jira/browse/LOG4J2-2455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16657695#comment-16657695
]
Gary Gregory commented on LOG4J2-2455:
--------------------------------------
Hi [~bhaveshhpatel],
Please feel free to submit a PR on GitHub:
https://github.com/apache/logging-log4j2/
Gary
> ResourceBundleLookup does not work with default values
> ------------------------------------------------------
>
> Key: LOG4J2-2455
> URL: https://issues.apache.org/jira/browse/LOG4J2-2455
> Project: Log4j 2
> Issue Type: Bug
> Components: Lookups
> Affects Versions: 2.11.1
> Reporter: Bhavesh Patel
> Priority: Minor
>
> ResourceBundleLookup for Log4j 2 work incorrectly with default values. If you
> do a lookup using the following
> {code:java}
> ${bundle:application:application.name}{code}
> it would work fine and return the value for application.name, if present.
> But if you want to use a default value, incase if the key is not found, the
> lookup functions incorrectly. If you do a lookup using the following
> {code:java}
> ${bundle:application:application.name:-None}{code}
> the lookup should return "None" if the application key is not found. But
> this particular lookup will always return "None" even if the key is present
> in the specified resource bundle.
> The issue seems to be that the _resolveVariable()_ in
> _org.apache.logging.log4j.core.lookup.StrSubstitutor_ class returns null; as
> the resolver is not able to perform the lookup correctly. The issue tracks
> back to _org.apache.logging.log4j.core.lookup.Interpolator_ class. The
> constructor
> _Interpolator(final Map<String, String> properties)_ does not add
> ResourceBundleLookup to the "strLookupMap".
> The fix is to add the ResourceBundleLookup to this map and then the bundle
> lookup functions correctly with the default value. The test for this feature,
> _ResourceBundleLookupTest.java_, needs to be updated to test for this
> scenario.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)