Philipp Knobel created LOG4J2-1454:
--------------------------------------
Summary: CompositeConfiguration fails if one configuration file
can't be found
Key: LOG4J2-1454
URL: https://issues.apache.org/jira/browse/LOG4J2-1454
Project: Log4j 2
Issue Type: Bug
Components: Configurators
Affects Versions: 2.6
Reporter: Philipp Knobel
Let's assume we have a composite configuration like:
_log4j.configurationFile=a.xml,b.json_ . If now any of those configs doesn't
exist one will get an exception:
{noformat}
2016-07-05 10:36:49,776 main ERROR File not found in file system or classpath:
a.xml
2016-07-05 10:36:56,949 main ERROR Failed to created configuration at a.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException: No Configuration was provided
at java.util.Objects.requireNonNull(Objects.java:228)
at
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:477)
at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:307)
at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59)
at org.apache.log4j.Logger.getLogger(Logger.java:41)
at my.package.Runner<clinit>(Runner.java:38)
{noformat}
This is due to this code:
{code}
for (final String sourceLocation : sources) {
final Configuration config =
getConfiguration(sourceLocation.trim());
if (config != null && config instanceof
AbstractConfiguration) {
configs.add((AbstractConfiguration) config);
} else {
LOGGER.error("Failed to created configuration
at {}", sourceLocation);
return null;
}
}
{code}
This seems wrong to me, as I would consider all configurations except the first
one optional (one could argue that even the first one might be an optional
one). Anyway it likely shouldn't happen that the application is dying with an
NPE due to bad log configuration.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]