Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2355

PropertiesUtil.reload() might throw NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.11.0
    • 2.11.1, 3.0.0
    • API
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              monti Henrik
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: