Skip to content

Commit 1bee6a6

Browse files
pbodnarjvz
authored andcommitted
Fix NPE in ContextSelector.getContext() (apache#1538 LOG4J2-3217)
1 parent 70ad886 commit 1bee6a6

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
@@ -84,7 +84,7 @@ default boolean hasContext(final String fqcn, final ClassLoader loader, final bo
8484
*/
8585
default LoggerContext getContext(final String fqcn, final ClassLoader loader, final Map.Entry<String, Object> entry, final boolean currentContext) {
8686
final LoggerContext lc = getContext(fqcn, loader, currentContext);
87-
if (entry != null) {
87+
if (lc != null && entry != null) {
8888
lc.putObject(entry.getKey(), entry.getValue());
8989
}
9090
return lc;
@@ -114,7 +114,7 @@ default LoggerContext getContext(final String fqcn, final ClassLoader loader, fi
114114
default LoggerContext getContext(final String fqcn, final ClassLoader loader, final Map.Entry<String, Object> entry,
115115
final boolean currentContext, final URI configLocation) {
116116
final LoggerContext lc = getContext(fqcn, loader, currentContext, configLocation);
117-
if (entry != null) {
117+
if (lc != null && entry != null) {
118118
lc.putObject(entry.getKey(), entry.getValue());
119119
}
120120
return lc;

0 commit comments

Comments
 (0)