Bhavesh Patel created LOG4J2-2455:
-------------------------------------
Summary: 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
ResourceBundleLookup for Log4j 2 work incorrectly with default values. If you
do a lookup using the following
${bundle:application:application.name}
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
${bundle:application:application.name:-None}
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)