]> source.dussan.org Git - sonarqube.git/commitdiff
Improve quality
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 8 Feb 2016 08:30:34 +0000 (09:30 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 8 Feb 2016 08:38:48 +0000 (09:38 +0100)
sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdIndexer.java

index 7e15a6a96ff747eb1c430fbc5a50d568376ddee5..381e7d558c67ac0dbb37b0806f4aae10c1f2299f 100644 (file)
@@ -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);