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

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

Commit b0e5a134487c5b8778d3706754654d428024de88 in logging-log4j2's branch 
refs/heads/master from [~henrik242]
[ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=b0e5a13 ]

[LOG4J2-2355] Avoid NullPointerException in PropertiesUtil.reload()

SystemPropertiesPropertySource.forEach(..) uses Property.getProperty(..)
to resolve values.  If that value is a non-String, the value will be
null.  Since `literal` is a ConcurrentHashMap, a put(..) with null value
will yield a NullPointerException.

This is especially hard to debug in the case of e.g. StatusLogger,
which initializes PropertiesUtil as a static variable.  The class is
unable to load, throws a NoClassDefFoundError, and hides the
NullPointerException.

Here's what I got when I had a Property value that was a File:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.logging.log4j.util.PropertiesUtil
        at 
org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:78)
        at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:60)


> PropertiesUtil.reload() might throw NullPointerException
> --------------------------------------------------------
>
>                 Key: LOG4J2-2355
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2355
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.11.0
>            Reporter: Henrik
>            Priority: Major
>
> SystemPropertiesPropertySource.forEach(..) uses Property.getProperty(..)
> to resolve values. If that value is a non-String, the value will be
> null. Since {{literal}} is a ConcurrentHashMap, a put(..) with null value
> will yield a NullPointerException.
> This is especially hard to debug in the case of e.g. StatusLogger,
> which initializes PropertiesUtil as a static variable. The class is
> unable to load, throws a NoClassDefFoundError, and hides the
> NullPointerException.
> Here's what I got when I had a Property value that was a File:
> Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
> org.apache.logging.log4j.util.PropertiesUtil
> at org.apache.logging.log4j.status.StatusLogger.(StatusLogger.java:78)
> at org.apache.logging.log4j.LogManager.(LogManager.java:60)
>  
> PR: https://github.com/apache/logging-log4j2/pull/183



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to