Skip to content

Commit c91fe38

Browse files
pbodnarvy
authored andcommitted
Fix NPE in ContextSelector.getContext() (#1538 LOG4J2-3217)
1 parent 57bdfd6 commit c91fe38

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ default boolean hasContext(final String fqcn, final ClassLoader loader, final bo
8282
*/
8383
default LoggerContext getContext(final String fqcn, final ClassLoader loader, final Map.Entry<String, Object> entry, final boolean currentContext) {
8484
final LoggerContext lc = getContext(fqcn, loader, currentContext);
85-
if (entry != null) {
85+
if (lc != null && entry != null) {
8686
lc.putObject(entry.getKey(), entry.getValue());
8787
}
8888
return lc;
@@ -112,7 +112,7 @@ default LoggerContext getContext(final String fqcn, final ClassLoader loader, fi
112112
default LoggerContext getContext(final String fqcn, final ClassLoader loader, final Map.Entry<String, Object> entry,
113113
final boolean currentContext, final URI configLocation) {
114114
final LoggerContext lc = getContext(fqcn, loader, currentContext, configLocation);
115-
if (entry != null) {
115+
if (lc != null && entry != null) {
116116
lc.putObject(entry.getKey(), entry.getValue());
117117
}
118118
return lc;

0 commit comments

Comments
 (0)