lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r791246 - /lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
Date Sun, 05 Jul 2009 14:01:15 GMT
Author: markrmiller
Date: Sun Jul  5 14:01:14 2009
New Revision: 791246

URL: http://svn.apache.org/viewvc?rev=791246&view=rev
Log:
reader should be closed after use

Modified:
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java?rev=791246&r1=791245&r2=791246&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
Sun Jul  5 14:01:14 2009
@@ -65,27 +65,32 @@
         }
       }
       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;



Mime
View raw message