in src/main/java/org/apache/sling/commons/log/logback/internal/LogConfigManager.java [1360:1401]
public void configChanged() {
if (!started) {
logger.debug("LoggerContext is not started so skipping reset handling");
return;
}
/*
Logback reset cannot be done concurrently. So when Logback is being reset
we note down any new request for reset. Later when the thread which performs
reset finishes, then it checks if any request for reset pending. if yes
then it again tries to reschedules a job to perform reset in rescheduleIfConfigChanged
Logback reset is done under a lock 'resetLock' so that Logback
is not reconfigured concurrently. Only the thread which acquires the
'resetLock' can submit the task for reload (actual reload done async)
Once the reload is done the lock is released in LoggerReconfigurer#run
The way locking works is any thread which changes config
invokes configChanged. Here two things are possible
1. Log reset in progress i.e. resetLock already acquired
In this case the thread would just set the 'configChanged' flag to true
2. No reset in progress. Thread would acquire the resetLock and submit the
job to reset Logback
Any such change is synchronized with configChangedFlagLock such that a request
for config changed is not missed
*/
synchronized (configChangedFlagLock) {
if (resetLock.tryAcquire()) {
configChanged = false;
scheduleConfigReload();
} else {
configChanged = true;
addInfo("LoggerContext reset in progress. Marking config changed to true");
}
}
}