[
https://issues.apache.org/jira/browse/LOG4J2-2455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629449#comment-16629449
]
Bhavesh Patel commented on LOG4J2-2455:
---------------------------------------
I have a fix for this issue and can also update the test to verify the fix. I
have experience contributing to OpenSource project as I am a contributor and a
reviewer on OpenJDK ([http://openjdk.java.net/census#bpatel)] and my
contribution to the OpenJDK project can be viewed at
([http://hg.openjdk.java.net/jdk/jdk/search/?rev=author%28bpatel%29&revcount=2560)].
Let me know if the Log4j 2 community would like me to work on contributing
this fix to the project. Any pointers on becoming a contributor to the project
would be really helpful.
> 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
> ${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)