aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2019-03-05 09:59:43 +0100
committerSonarTech <sonartech@sonarsource.com>2019-03-08 20:20:55 +0100
commitf6b2a269c44043f1c230b646dbb8662aed3fa5a4 (patch)
tree748f02bcbe36adf577afadb68de6a40ebe6dc83e /sonar-scanner-protocol/src
parent8fb0a6166734d74674d93863cc4556388a0154e9 (diff)
downloadsonarqube-f6b2a269c44043f1c230b646dbb8662aed3fa5a4.tar.gz
sonarqube-f6b2a269c44043f1c230b646dbb8662aed3fa5a4.zip
SONAR-11795 Drop persistit and move coverage measures computation to CE side
Diffstat (limited to 'sonar-scanner-protocol/src')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java9
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java2
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java2
3 files changed, 8 insertions, 5 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
index e20e37ff852..42292da429b 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
@@ -112,10 +112,13 @@ public class ScannerReportWriter {
}
}
- public File writeComponentMeasures(int componentRef, Iterable<ScannerReport.Measure> measures) {
+ public void appendComponentMeasure(int componentRef, ScannerReport.Measure measure) {
File file = fileStructure.fileFor(FileStructure.Domain.MEASURES, componentRef);
- Protobuf.writeStream(measures, file, false);
- return file;
+ try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file, true))) {
+ measure.writeDelimitedTo(out);
+ } catch (Exception e) {
+ throw ContextException.of("Unable to write measure", e).addContext("file", file);
+ }
}
public File writeComponentChangesets(ScannerReport.Changesets changesets) {
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
index 928166b5a31..b405c69cbe3 100644
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
+++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
@@ -124,7 +124,7 @@ public class ScannerReportReaderTest {
ScannerReportWriter writer = new ScannerReportWriter(dir);
ScannerReport.Measure.Builder measure = ScannerReport.Measure.newBuilder()
.setStringValue(StringValue.newBuilder().setValue("value_a"));
- writer.writeComponentMeasures(1, asList(measure.build()));
+ writer.appendComponentMeasure(1, measure.build());
assertThat(underTest.readComponentMeasures(1)).hasSize(1);
}
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
index 3a6f84961dd..ade53f3bca5 100644
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
+++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
@@ -183,7 +183,7 @@ public class ScannerReportWriterTest {
.setDoubleValue(DoubleValue.newBuilder().setValue(2.5d).setData("text-value"))
.build();
- underTest.writeComponentMeasures(1, asList(measure));
+ underTest.appendComponentMeasure(1, measure);
assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue();
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1);