File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
log4j-jul/src/main/java/org/apache/logging/log4j/jul Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -175,15 +175,19 @@ public void publish(LogRecord record) {
175
175
return ;
176
176
}
177
177
178
+ // Only execute synchronized code if we really have to
178
179
if (this .installAsLevelPropagator ) {
179
180
synchronized (this ) {
180
- @ SuppressWarnings ("resource" ) // no need to close the AutoCloseable ctx here
181
- LoggerContext context = LoggerContext .getContext (false );
182
- context .addPropertyChangeListener (this );
183
- propagateLogLevels (context .getConfiguration ());
184
- // note: java.util.logging.LogManager.addPropertyChangeListener() could also
185
- // be set here, but a call of JUL.readConfiguration() will be done on purpose
186
- this .installAsLevelPropagator = false ;
181
+ // Check again to make sure we still have to propagate the levels at this point
182
+ if (this .installAsLevelPropagator ) {
183
+ @ SuppressWarnings ("resource" ) // no need to close the AutoCloseable ctx here
184
+ LoggerContext context = LoggerContext .getContext (false );
185
+ context .addPropertyChangeListener (this );
186
+ propagateLogLevels (context .getConfiguration ());
187
+ // note: java.util.logging.LogManager.addPropertyChangeListener() could also
188
+ // be set here, but a call of JUL.readConfiguration() will be done on purpose
189
+ this .installAsLevelPropagator = false ;
190
+ }
187
191
}
188
192
}
189
193
You can’t perform that action at this time.
0 commit comments