reader should be closed after use

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@791246 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2009-07-05 14:01:14 +00:00
parent b0873e4476
commit 9789089343
1 changed files with 19 additions and 14 deletions

View File

@ -65,27 +65,32 @@ public class FileBasedQueryMaker extends AbstractQueryMaker implements QueryMake
}
}
if (reader != null) {
BufferedReader buffered = new BufferedReader(reader);
String line = null;
int lineNum = 0;
while ((line = buffered.readLine()) != null)
{
line = line.trim();
if (!line.equals("") && !line.startsWith("#"))
try {
BufferedReader buffered = new BufferedReader(reader);
String line = null;
int lineNum = 0;
while ((line = buffered.readLine()) != null)
{
Query query = null;
try {
query = qp.parse(line);
} catch (ParseException e) {
System.err.println("Exception: " + e.getMessage() + " occurred while parsing line: " + lineNum + " Text: " + line);
line = line.trim();
if (!line.equals("") && !line.startsWith("#"))
{
Query query = null;
try {
query = qp.parse(line);
} catch (ParseException e) {
System.err.println("Exception: " + e.getMessage() + " occurred while parsing line: " + lineNum + " Text: " + line);
}
qq.add(query);
}
qq.add(query);
lineNum++;
}
lineNum++;
} finally {
reader.close();
}
} else {
System.err.println("No Reader available for: " + fileName);
}
}
Query [] result = (Query[]) qq.toArray(new Query[qq.size()]) ;
return result;