-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code
Milestone
Description
Description
In a Spring Boot application Log4j Core is initialized at least twice:
- the first initialization is the static Log4j Core initialization (Spring's
Environmentis not available yet), - the second initialization is performed programmatically by Spring Boot as soon as it creates an
Environment. It can use the same configuration file as the first one.
On the other hand the builder of SpringProfileArbiter returns null if no Spring Environment is present, which causes (handled) NullPointerExceptions in AbstractConfiguration#processConditionals or AbstractConfiguration#processSelect.
Since the arbiter logic itself accepts a null environment, we should remove the following null-check:
environment = (Environment) loggerContext.getObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY);
if (environment == null) {
LOGGER.warn("Cannot create Arbiter, no Spring Environment provided");
return null;
}The fix should be propagated to the Spring Boot project.
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code