aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol/src/main/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-03-05 11:08:17 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-03-05 11:10:00 +0100
commit33e7b484acb9b0cda2e638dd5356b5e33c0ec1b4 (patch)
treeb0e198c98a182363d66a09c9a73ef4a22ea1d882 /sonar-batch-protocol/src/main/java
parent29f7b15feea86c67c8e75fb89c8fa0dd4b807ba8 (diff)
downloadsonarqube-33e7b484acb9b0cda2e638dd5356b5e33c0ec1b4.tar.gz
sonarqube-33e7b484acb9b0cda2e638dd5356b5e33c0ec1b4.zip
Fix quality flaws
Diffstat (limited to 'sonar-batch-protocol/src/main/java')
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java9
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java (renamed from sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchOutputWriter.java)4
2 files changed, 5 insertions, 8 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
index 72a319a4e09..a2cee3bd75f 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
@@ -22,8 +22,6 @@ package org.sonar.batch.protocol.output;
import org.sonar.batch.protocol.ProtobufUtil;
import org.sonar.batch.protocol.output.BatchReport.Issues;
-import javax.annotation.CheckForNull;
-
import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -44,13 +42,12 @@ public class BatchReportReader {
return ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER);
}
- @CheckForNull
public BatchReport.Component readComponent(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.COMPONENT, componentRef);
- if (file.exists() && file.isFile()) {
- return ProtobufUtil.readFile(file, BatchReport.Component.PARSER);
+ if (!file.exists() || !file.isFile()) {
+ throw new IllegalStateException("Unable to find report for component #" + componentRef + ". File does not exist: " + file);
}
- return null;
+ return ProtobufUtil.readFile(file, BatchReport.Component.PARSER);
}
public List<BatchReport.Issue> readComponentIssues(int componentRef) {
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchOutputWriter.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
index ce1ce341d6f..55ced1fa354 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchOutputWriter.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
@@ -23,11 +23,11 @@ import org.sonar.batch.protocol.ProtobufUtil;
import java.io.File;
-public class BatchOutputWriter {
+public class BatchReportWriter {
private final FileStructure fileStructure;
- public BatchOutputWriter(File dir) {
+ public BatchReportWriter(File dir) {
if (!dir.exists() && !dir.mkdirs()) {
throw new IllegalStateException("Unable to create directory: " + dir);
}