diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-09-28 11:44:44 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-09-28 11:44:44 +0200 |
commit | f85e6c5cb862c41a7cd2f0b20e02ab2294a91bf1 (patch) | |
tree | c94c8fe45afa3b68d98816a361e1e72936aa35b5 /server/sonar-process | |
parent | 4d86f6f1f4b965b7618f6d81ecfa303f89247bee (diff) | |
download | sonarqube-f85e6c5cb862c41a7cd2f0b20e02ab2294a91bf1.tar.gz sonarqube-f85e6c5cb862c41a7cd2f0b20e02ab2294a91bf1.zip |
Fix instability of LogbackHelper
Diffstat (limited to 'server/sonar-process')
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java index 6d08fe19f92..7ba6393a3d6 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java @@ -48,7 +48,21 @@ public class LogbackHelper { public static final String MAX_FILES_PROPERTY = "sonar.log.maxFiles"; public LoggerContext getRootContext() { - return ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getLoggerContext(); + org.slf4j.Logger logger; + while (!((logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)) instanceof Logger)) { + // It occurs when the initialization step is still not finished because of a race condition + // on ILoggerFactory.getILoggerFactory + // http://jira.qos.ch/browse/SLF4J-167 + // Substitute loggers are used. + // http://www.slf4j.org/codes.html#substituteLogger + // Bug is not fixed in SLF4J 1.7.14. + try { + Thread.sleep(10); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + return ((Logger) logger).getLoggerContext(); } public LoggerContextListener enableJulChangePropagation(LoggerContext loggerContext) { |