diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-30 16:34:38 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-30 16:35:10 +0200 |
commit | d44ef046f3dd7d59397c681cb79ebe3173d915bb (patch) | |
tree | 2851cb4dfd1c297e3e2cbdefb8b54d59f0ce06e0 /sonar-batch | |
parent | ef9b3e8704be8de9f30c42f9e8034588309f6e16 (diff) | |
download | sonarqube-d44ef046f3dd7d59397c681cb79ebe3173d915bb.tar.gz sonarqube-d44ef046f3dd7d59397c681cb79ebe3173d915bb.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-batch')
4 files changed, 15 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java index ac107141bc3..b448c2ad076 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -62,7 +62,7 @@ public final class Batch { * @deprecated since 4.4 use {@link #start()}, {@link #executeTask(Map)} and then {@link #stop()} */ @Deprecated - public Batch execute() { + public synchronized Batch execute() { configureLogging(); start().executeTask(bootstrapProperties).stop(); return this; @@ -105,6 +105,8 @@ public final class Batch { } bootstrapContainer.stopComponents(); + + this.started = false; } private void configureLogging() { diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java index 689b6a0e4cd..7eeb87ea4f9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.index; +import org.sonar.api.resources.Language; + import com.google.common.collect.Maps; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -294,8 +296,9 @@ public final class DefaultResourcePersister implements ResourcePersister { model.setDescription(resource.getDescription()); model.setKey(resource.getEffectiveKey()); model.setPath(resource.getPath()); - if (resource.getLanguage() != null) { - model.setLanguageKey(resource.getLanguage().getKey()); + Language language = resource.getLanguage(); + if (language != null) { + model.setLanguageKey(language.getKey()); } if (StringUtils.isNotBlank(resource.getName())) { model.setName(resource.getName()); @@ -327,8 +330,9 @@ public final class DefaultResourcePersister implements ResourcePersister { model.setScope(resource.getScope()); model.setQualifier(resource.getQualifier()); } - if (resource.getLanguage() != null) { - model.setLanguageKey(resource.getLanguage().getKey()); + Language language = resource.getLanguage(); + if (language != null) { + model.setLanguageKey(language.getKey()); } } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java index 514bbc9d3d4..e20680b10fc 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java @@ -38,7 +38,7 @@ public final class DependencyPersister { public void saveDependency(Project project, Dependency dependency, Dependency parentDependency) { Snapshot fromSnapshot = resourcePersister.saveResource(project, dependency.getFrom()); Snapshot toSnapshot = resourcePersister.saveResource(project, dependency.getTo()); - Snapshot projectSnapshot = resourcePersister.getSnapshot(project); + Snapshot projectSnapshot = resourcePersister.getSnapshotOrFail(project); DependencyDto model = new DependencyDto(); model.setProjectSnapshotId(projectSnapshot.getId()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java index bac550fd878..e1bf875059f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java @@ -146,6 +146,9 @@ public class AnalyzerContextAdaptor implements AnalyzerContext { @Override public void addMeasure(AnalyzerMeasure<?> measure) { org.sonar.api.measures.Metric<?> m = metricFinder.findByKey(measure.metric().key()); + if (m == null) { + throw new IllegalStateException("Unknow metric with key: " + measure.metric().key()); + } Measure measureToSave = new Measure(m); switch (m.getType()) { |