Andrei Terentiev created LOG4J2-2844:
----------------------------------------
Summary: Null pointer exception when no network interfaces are
available
Key: LOG4J2-2844
URL: https://issues.apache.org/jira/browse/LOG4J2-2844
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.13.2
Reporter: Andrei Terentiev
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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)