ppkarwasz commented on code in PR #2062:
URL: https://github.com/apache/logging-log4j2/pull/2062#discussion_r1415325063
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java:
##########
@@ -146,8 +149,12 @@ public LoggerContext getContext(
if (externalContext != null && ctx.getExternalContext() == null) {
ctx.setExternalContext(externalContext);
}
- if (ctx.getState() == LifeCycle.State.INITIALIZED) {
- startContext(ctx, classLoader);
+ try {
+ if (ctx.getState() == LifeCycle.State.INITIALIZED) {
+ startContext(ctx, classLoader);
+ }
+ } catch (IllegalStateException ex) {
+ return internalContext;
Review Comment:
I agree on the need to log a `WARN` message or even an `ERROR` message.
In these kind of situations users are really clueless on why their Log4j
configuration is not working. Problems concerning multiple `LoggerContext`s are
the hardest to debug. Users usually **don't** know that multiple logger
contexts are possible (this is _almost_ exclusive to Log4j Core).
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java:
##########
@@ -118,6 +121,15 @@ protected boolean isActive() {
return true;
}
+ /**
+ * Required for Spring Boot.
+ * @param props PropertiesUtil.
+ * @return the AuthorizationProvider, if any.
+ */
+ public static AuthorizationProvider authorizationProvider(final
PropertiesUtil props) {
+ return
AuthorizationProvider.getAuthorizationProvider((PropertyEnvironment) props);
+ }
Review Comment:
I agree that the method should not be duplicated.
Also, in order to make this PR back-portable to `2.x` (it is a requirement,
isn't it?), I would use `LoggerContext` as parameter.
Unless I am mistaken, all HTTP/HTTPS accesses are performed **after** a
`LoggerContext` is created and the context is passed to the
`ConfigurationFactory` as a parameter (since 2.7). This change would allow 3.x
to configure separate credentials for separate web applications.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]