]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2804 Fix bug when unit test data missing
authorDavid Gageot <david@gageot.net>
Mon, 15 Oct 2012 08:39:53 +0000 (10:39 +0200)
committerDavid Gageot <david@gageot.net>
Mon, 15 Oct 2012 08:39:53 +0000 (10:39 +0200)
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java

index 378b1e86eec7a50ca213708fcf0f4909efa43137..5319ca72ce0132b9f28f9ab3be1467b0de688fcb 100644 (file)
@@ -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);
+        }
       }
     }
   }