From 33f552bfc1daac517935c7df595be06a3c335824 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Wed, 29 Oct 2014 16:45:25 +0100 Subject: [PATCH] removed potential bug in countLines --- src/test/java/teetime/framework/FileSearcherTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/test/java/teetime/framework/FileSearcherTest.java b/src/test/java/teetime/framework/FileSearcherTest.java index 1712da57..81419099 100644 --- a/src/test/java/teetime/framework/FileSearcherTest.java +++ b/src/test/java/teetime/framework/FileSearcherTest.java @@ -88,7 +88,7 @@ public class FileSearcherTest { } private IPipeFactory getClassByString(final String string) throws ClassNotFoundException, InstantiationException, IllegalAccessException { - Class<?> clazz = Class.forName(string); // TODO: try-catch + Class<?> clazz = Class.forName(string); Class<? extends IPipeFactory> pipeFactoryClass = clazz.asSubclass(IPipeFactory.class); return pipeFactoryClass.newInstance(); } @@ -97,10 +97,13 @@ public class FileSearcherTest { private int countLines(final File fileName) throws IOException { BufferedReader fileReader = new BufferedReader(new FileReader(fileName)); int lines = 0; - while (fileReader.readLine() != null) { // TODO: Finally - lines = lines + 1; + try { + while (fileReader.readLine() != null) { // TODO: Finally + lines = lines + 1; + } + } finally { + fileReader.close(); } - fileReader.close(); return lines; } -- GitLab