From 6aff1b068d8d68493d357ca48c204dac1dc0ddea Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Mon, 8 Feb 2016 09:30:34 +0100 Subject: [PATCH] Improve quality --- .../main/java/org/sonar/batch/cpd/JavaCpdIndexer.java | 9 ++++----- 1 file 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 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 blocks = blockChunker.chunk(resourceEffectiveKey, statements); -- 2.39.5