Skip to content
Snippets Groups Projects
Commit 14bba8f7 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

removed potential bug in countLines

parent e107f00d
Branches
No related tags found
No related merge requests found
...@@ -88,7 +88,7 @@ public class FileSearcherTest { ...@@ -88,7 +88,7 @@ public class FileSearcherTest {
} }
private IPipeFactory getClassByString(final String string) throws ClassNotFoundException, InstantiationException, IllegalAccessException { 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); Class<? extends IPipeFactory> pipeFactoryClass = clazz.asSubclass(IPipeFactory.class);
return pipeFactoryClass.newInstance(); return pipeFactoryClass.newInstance();
} }
...@@ -97,10 +97,13 @@ public class FileSearcherTest { ...@@ -97,10 +97,13 @@ public class FileSearcherTest {
private int countLines(final File fileName) throws IOException { private int countLines(final File fileName) throws IOException {
BufferedReader fileReader = new BufferedReader(new FileReader(fileName)); BufferedReader fileReader = new BufferedReader(new FileReader(fileName));
int lines = 0; int lines = 0;
try {
while (fileReader.readLine() != null) { // TODO: Finally while (fileReader.readLine() != null) { // TODO: Finally
lines = lines + 1; lines = lines + 1;
} }
} finally {
fileReader.close(); fileReader.close();
}
return lines; return lines;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment