diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-06-24 11:42:18 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-07-01 20:05:53 +0000 |
commit | db6fdba06563d8e5cb39ddaabec976f2db6a1448 (patch) | |
tree | c97f68aedaf59ccb6e62dfc42aa2a6d0340107a3 /server/sonar-webserver-core | |
parent | db5fc175198e954404be2a9d73d63b7e3c19af49 (diff) | |
download | sonarqube-db6fdba06563d8e5cb39ddaabec976f2db6a1448.tar.gz sonarqube-db6fdba06563d8e5cb39ddaabec976f2db6a1448.zip |
Fix unit test FP
Diffstat (limited to 'server/sonar-webserver-core')
-rw-r--r-- | server/sonar-webserver-core/src/main/java/org/sonar/server/qualitygate/ProjectsInWarningDaemon.java | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/qualitygate/ProjectsInWarningDaemon.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/qualitygate/ProjectsInWarningDaemon.java index 15eb5b5768c..f1e5559c9d1 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/qualitygate/ProjectsInWarningDaemon.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/qualitygate/ProjectsInWarningDaemon.java @@ -40,7 +40,7 @@ import static org.sonar.api.measures.Metric.Level.WARN; /** * This class is regularly checking the number of projects in warning state, in order to not return the "Warning" value in the quality gate facet of the Projects page when there are no more projects in warning. - * + * * @see <a href="https://jira.sonarsource.com/browse/SONAR-12140">SONAR-12140</a> for more information */ public class ProjectsInWarningDaemon implements Startable { @@ -93,21 +93,22 @@ public class ProjectsInWarningDaemon implements Startable { private Runnable countProjectsInWarning() { return () -> { + long nbProjectsInWarning = projectMeasuresIndex.search( + new ProjectMeasuresQuery() + .setQualityGateStatus(WARN) + .setIgnoreAuthorization(true), + // We only need the number of projects in warning + new SearchOptions().setLimit(1)).getTotal(); + try (DbSession dbSession = dbClient.openSession(false)) { - long nbProjectsInWarning = projectMeasuresIndex.search( - new ProjectMeasuresQuery() - .setQualityGateStatus(WARN) - .setIgnoreAuthorization(true), - // We only need the number of projects in warning - new SearchOptions().setLimit(1)).getTotal(); - projectsInWarning.update(nbProjectsInWarning); updateProjectsInWarningInDb(dbSession, nbProjectsInWarning); - if (nbProjectsInWarning == 0L) { - LOG.info("Counting number of projects in warning will be disabled as there are no more projects in warning."); - executorService.shutdown(); - } } catch (Exception e) { - LOG.error("Error while counting number of projects in warning: {}", e); + LOG.error("Error updating number of projects in warning: {}", e); + } + projectsInWarning.update(nbProjectsInWarning); + if (nbProjectsInWarning == 0L) { + LOG.info("Counting number of projects in warning will be disabled as there are no more projects in warning."); + executorService.shutdown(); } }; } |