aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-10-15 10:39:53 +0200
committerDavid Gageot <david@gageot.net>2012-10-15 10:39:53 +0200
commit92f455820d908fdd622b1051361b05e285ab9bcf (patch)
tree41a7086e6d604dd3a3670e112f8bbbbba5054721
parentb0f5591e3d4cb08834ad7c50a253e0da57aab3db (diff)
downloadsonarqube-92f455820d908fdd622b1051361b05e285ab9bcf.tar.gz
sonarqube-92f455820d908fdd622b1051361b05e285ab9bcf.zip
SONAR-2804 Fix bug when unit test data missing
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
index 378b1e86eec..5319ca72ce0 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
@@ -89,17 +89,19 @@ public class JaCoCoOverallSensor implements Sensor {
private void loadSourceFiles(SessionInfoStore infoStore, ExecutionDataStore dataStore, File... files) {
for (File file : files) {
- InputStream resourceStream = null;
- try {
- resourceStream = new BufferedInputStream(new FileInputStream(file));
- ExecutionDataReader reader = new ExecutionDataReader(resourceStream);
- reader.setSessionInfoVisitor(infoStore);
- reader.setExecutionDataVisitor(dataStore);
- reader.read();
- } catch (IOException e) {
- throw new SonarException(String.format("Unable to read %s", file.getAbsolutePath()), e);
- } finally {
- Closeables.closeQuietly(resourceStream);
+ if (file.exists()) {
+ InputStream resourceStream = null;
+ try {
+ resourceStream = new BufferedInputStream(new FileInputStream(file));
+ ExecutionDataReader reader = new ExecutionDataReader(resourceStream);
+ reader.setSessionInfoVisitor(infoStore);
+ reader.setExecutionDataVisitor(dataStore);
+ reader.read();
+ } catch (IOException e) {
+ throw new SonarException(String.format("Unable to read %s", file.getAbsolutePath()), e);
+ } finally {
+ Closeables.closeQuietly(resourceStream);
+ }
}
}
}