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

Null pointer exception when no network interfaces are available

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.13.2
    • 3.0.0, 2.14.0
    • Core
    • None

    Description

      Hi,

        java.net.NetworkInterface.getNetworkInterfaces() returns null when no network interfaces are available (e.g. networking is disabled at the moment) - see https://docs.oracle.com/javase/7/docs/api/java/net/NetworkInterface.html#getNetworkInterfaces().

      Seems that the line 98 of org.apache.logging.log4j.core.util.NetUtils.java should have a null check.

      Here is a stack trace:

      Exception in thread "main" java.lang.ExceptionInInitializerError
      at org.apache.logging.log4j.core.util.WatchManager.<init>(WatchManager.java:53)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:135)
      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:32)
      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:86)
      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:229)
      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:203)
      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:128)
      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:115)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
      at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:602)
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:588)
      at App$1.<init>(App.java:36)
      Caused by: java.lang.NullPointerException
      at org.apache.logging.log4j.core.util.NetUtils.getMacAddress(NetUtils.java:98)
      at org.apache.logging.log4j.core.util.UuidUtil.<clinit>(UuidUtil.java:64)
      ... 18 more

      Attachments

        Activity

          People

            Unassigned Unassigned
            aksian Andrei Terentiev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: