diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-03-11 12:11:03 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-03-11 12:11:10 +0100 |
commit | 339c8f6b3cd44c5c305ee6e82b4c55c958fb1788 (patch) | |
tree | bc3b39c43a76cc6cec99efb512574d93f9f99e3f /sonar-batch/src/main/java/org/sonar/batch | |
parent | 4ed48fb36439af64821def82ecbe546ec47deede (diff) | |
download | sonarqube-339c8f6b3cd44c5c305ee6e82b4c55c958fb1788.tar.gz sonarqube-339c8f6b3cd44c5c305ee6e82b4c55c958fb1788.zip |
SONAR-5094 Memoize loaded quality gate (do not reload on next provide call)
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java index 3cfba31d384..d628cd324b7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java @@ -40,8 +40,13 @@ public class QualityGateProvider extends ProviderAdapter { private static final String PROPERTY_QUALITY_GATE = "sonar.qualitygate"; + private QualityGate instance; + public QualityGate provide(Settings settings, ServerClient client, MetricFinder metricFinder) { - return init(settings, client, metricFinder, LOG); + if (instance == null) { + instance = init(settings, client, metricFinder, LOG); + } + return instance; } @VisibleForTesting @@ -52,8 +57,8 @@ public class QualityGateProvider extends ProviderAdapter { logger.info("No quality gate is configured."); } else { result = load(qualityGateSetting, client.wsClient().qualityGateClient(), metricFinder); + logger.info("Loaded quality gate '{}'", result.name()); } - logger.info("Loaded quality gate '{}'", result.name()); return result; } |