diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-07-10 10:38:27 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-07-11 08:51:38 +0200 |
commit | 6f107dcbe90b0fea564e1ecaa96643bfc539329a (patch) | |
tree | 45478253f6006a0f1381fb506f92852ad2f5c5df /sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure | |
parent | f6a0f6bb86f7d244bec0b6781020e2ea066124c6 (diff) | |
download | sonarqube-6f107dcbe90b0fea564e1ecaa96643bfc539329a.tar.gz sonarqube-6f107dcbe90b0fea564e1ecaa96643bfc539329a.zip |
SONAR-9477 Deprecate ProjectReactor and ProjectBuilder
Mark Immutable classes in the Plugin API and Scanner
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/DefaultMetricFinder.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/DefaultMetricFinder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/DefaultMetricFinder.java index 00d484ef598..c6655b7d570 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/DefaultMetricFinder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/DefaultMetricFinder.java @@ -22,21 +22,28 @@ package org.sonar.scanner.scan.measure; import com.google.common.collect.Lists; import java.io.Serializable; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + +import javax.annotation.concurrent.ThreadSafe; + import org.sonar.api.batch.measure.Metric; import org.sonar.api.batch.measure.MetricFinder; import org.sonar.scanner.repository.MetricsRepository; +@ThreadSafe public class DefaultMetricFinder implements MetricFinder { - private Map<String, Metric<Serializable>> metricsByKey = new LinkedHashMap<>(); + private Map<String, Metric<Serializable>> metricsByKey; public DefaultMetricFinder(MetricsRepository metricsRepository) { + Map<String, Metric<Serializable>> metrics = new LinkedHashMap<>(); for (org.sonar.api.measures.Metric metric : metricsRepository.metrics()) { - metricsByKey.put(metric.key(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), metric.getType()).create()); + metrics.put(metric.key(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), metric.getType()).create()); } + metricsByKey = Collections.unmodifiableMap(metrics); } @Override |