aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-01-28 17:40:30 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-01-28 17:41:28 +0100
commitcc8788c9ea25a29e55aadab81d3468c9ee74c9aa (patch)
treebb1d4bf844e4c7f0f8d64671d9e5f077669a7eea /sonar-batch
parent277f4ed0a860f676d7fbaf239da723e0ae6f34f6 (diff)
downloadsonarqube-cc8788c9ea25a29e55aadab81d3468c9ee74c9aa.tar.gz
sonarqube-cc8788c9ea25a29e55aadab81d3468c9ee74c9aa.zip
SONAR-2291 Close InputStream properly after computing md5
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/SonarCache.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/SonarCache.java b/sonar-batch/src/main/java/org/sonar/batch/cache/SonarCache.java
index bd203b2d17b..b503dc463df 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/SonarCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/SonarCache.java
@@ -19,6 +19,7 @@
*/
package org.sonar.batch.cache;
+import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
@@ -107,8 +108,14 @@ public class SonarCache {
tmpFileName = sourceFile;
}
// Now compute the md5 to find the final destination
- FileInputStream fis = new FileInputStream(tmpFileName);
- String md5 = DigestUtils.md5Hex(fis);
+ String md5;
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(tmpFileName);
+ md5 = DigestUtils.md5Hex(fis);
+ } finally {
+ Closeables.closeQuietly(fis);
+ }
File finalDir = new File(cacheLocation, md5);
File finalFileName = new File(finalDir, filename);
// Try to create final destination folder