From 978908934365e4b6016ae475c9e1ef3926ea1c4f Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 5 Jul 2009 14:01:14 +0000 Subject: [PATCH] reader should be closed after use git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@791246 13f79535-47bb-0310-9956-ffa450edef68 --- .../byTask/feeds/FileBasedQueryMaker.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java index 66f62df12de..dc36f02cd00 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java @@ -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;