You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by henrik242 <gi...@git.apache.org> on 2018/06/22 12:45:55 UTC

[GitHub] logging-log4j2 pull request #183: Avoid NullPointerException in PropertiesUt...

GitHub user henrik242 opened a pull request:

    https://github.com/apache/logging-log4j2/pull/183

    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)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/henrik242/logging-log4j2 skip-null-propery-value

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/logging-log4j2/pull/183.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #183
    
----
commit fef993fbb5cbeddfa1ac29a6a33d3dfe2e833053
Author: Henrik Brautaset Aronsen <he...@...>
Date:   2018-06-22T12:45:26Z

    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)

----


---

[GitHub] logging-log4j2 issue #183: [LOG4J2-2355] Avoid NullPointerException in Prope...

Posted by cakofony <gi...@git.apache.org>.
Github user cakofony commented on the issue:

    https://github.com/apache/logging-log4j2/pull/183
  
    I should have commented here -- I've taken care of it and added a test.


---

[GitHub] logging-log4j2 issue #183: [LOG4J2-2355] Avoid NullPointerException in Prope...

Posted by henrik242 <gi...@git.apache.org>.
Github user henrik242 commented on the issue:

    https://github.com/apache/logging-log4j2/pull/183
  
    Merged, see https://issues.apache.org/jira/browse/LOG4J2-2355 


---

[GitHub] logging-log4j2 pull request #183: [LOG4J2-2355] Avoid NullPointerException i...

Posted by henrik242 <gi...@git.apache.org>.
Github user henrik242 closed the pull request at:

    https://github.com/apache/logging-log4j2/pull/183


---

[GitHub] logging-log4j2 issue #183: [LOG4J2-2355] Avoid NullPointerException in Prope...

Posted by jvz <gi...@git.apache.org>.
Github user jvz commented on the issue:

    https://github.com/apache/logging-log4j2/pull/183
  
    Oh wow I missed the merge done elsewhere.


---