aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2016-02-08 09:30:34 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2016-02-08 09:38:48 +0100
commit6aff1b068d8d68493d357ca48c204dac1dc0ddea (patch)
tree9645fc34469ad9619b18c9bed55c7f741f616b43
parentb16866d9262240e4b0668f2c91cb187b65d88a76 (diff)
downloadsonarqube-6aff1b068d8d68493d357ca48c204dac1dc0ddea.tar.gz
sonarqube-6aff1b068d8d68493d357ca48c204dac1dc0ddea.zip
Improve quality
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java
index 7e15a6a96ff..381e7d558c6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java
@@ -22,6 +22,7 @@ package org.sonar.batch.cpd;
import com.google.common.collect.Lists;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
@@ -90,14 +91,12 @@ public class JavaCpdIndexer extends CpdIndexer {
List<Statement> statements;
- Reader reader = null;
- try {
- reader = new InputStreamReader(new FileInputStream(inputFile.file()), fs.encoding());
+ try(Reader reader = new InputStreamReader(new FileInputStream(inputFile.file()), fs.encoding())) {
statements = statementChunker.chunk(tokenChunker.chunk(reader));
} catch (FileNotFoundException e) {
throw new IllegalStateException("Cannot find file " + inputFile.file(), e);
- } finally {
- IOUtils.closeQuietly(reader);
+ } catch (IOException e ) {
+ throw new IllegalStateException("Exception hnadling file: " + inputFile.file(), e);
}
List<Block> blocks = blockChunker.chunk(resourceEffectiveKey, statements);