diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-05-02 09:13:09 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-05-02 09:13:09 +0200 |
commit | 79fc72db28d21def2db78fa113e370b46065f96c (patch) | |
tree | d951947c71c910a91a16bbc9145a88079d3a4891 /sonar-batch/src/main | |
parent | dfb3d2fc8cd965158e4335362adf31fb88d385a7 (diff) | |
download | sonarqube-79fc72db28d21def2db78fa113e370b46065f96c.tar.gz sonarqube-79fc72db28d21def2db78fa113e370b46065f96c.zip |
Revert "SONAR-3437 Enable batch mode when saving measures into DB"
This reverts commit 1b84be0cba036bc7d782f9191874bf144c6fe534.
Diffstat (limited to 'sonar-batch/src/main')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java index 2edf522df7a..09dfd493df2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java @@ -20,6 +20,7 @@ package org.sonar.batch.index; import com.google.common.annotations.VisibleForTesting; +import org.apache.ibatis.session.SqlSession; import org.sonar.api.database.model.MeasureMapper; import org.sonar.api.database.model.MeasureModel; import org.sonar.api.database.model.Snapshot; @@ -34,7 +35,6 @@ import org.sonar.api.technicaldebt.batch.Characteristic; import org.sonar.api.utils.SonarException; import org.sonar.batch.index.Cache.Entry; import org.sonar.batch.scan.measure.MeasureCache; -import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; public final class MeasurePersister implements ScanPersister { @@ -55,7 +55,7 @@ public final class MeasurePersister implements ScanPersister { @Override public void persist() { - DbSession session = mybatis.openSession(true); + SqlSession session = mybatis.openSession(); try { MeasureMapper mapper = session.getMapper(MeasureMapper.class); @@ -67,13 +67,16 @@ public final class MeasurePersister implements ScanPersister { if (shouldPersistMeasure(resource, measure)) { Snapshot snapshot = snapshotCache.get(effectiveKey); MeasureModel measureModel = model(measure).setSnapshotId(snapshot.getId()); - mapper.insert(measureModel); + try { + mapper.insert(measureModel); + } catch (Exception e) { + // SONAR-4066 + throw new SonarException(String.format("Unable to save measure for metric [%s] on component [%s]", measure.getMetricKey(), resource.getKey()), e); + } } } session.commit(); - } catch (Exception e) { - throw new SonarException("Unable to save some measures", e); } finally { MyBatis.closeQuietly(session); } |