Fixing BLUR-389.  Closing reader even if IOException is thrown.

Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/eec9d49e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/eec9d49e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/eec9d49e

Branch: refs/heads/master
Commit: eec9d49e9dc295b4150d5d1f80146418ac7701a8
Parents: 61c2235
Author: Aaron McCurry <[email protected]>
Authored: Wed Nov 5 21:24:41 2014 -0500
Committer: Aaron McCurry <[email protected]>
Committed: Wed Nov 5 21:24:41 2014 -0500

----------------------------------------------------------------------
 .../org/apache/blur/thrift/util/EnqueueDataAsync.java    | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/eec9d49e/blur-thrift/src/main/java/org/apache/blur/thrift/util/EnqueueDataAsync.java
----------------------------------------------------------------------
diff --git 
a/blur-thrift/src/main/java/org/apache/blur/thrift/util/EnqueueDataAsync.java 
b/blur-thrift/src/main/java/org/apache/blur/thrift/util/EnqueueDataAsync.java
index b405422..ad12a15 100644
--- 
a/blur-thrift/src/main/java/org/apache/blur/thrift/util/EnqueueDataAsync.java
+++ 
b/blur-thrift/src/main/java/org/apache/blur/thrift/util/EnqueueDataAsync.java
@@ -96,11 +96,14 @@ public class EnqueueDataAsync {
   private static void loadWords() throws IOException {
     InputStream inputStream = 
EnqueueDataAsync.class.getResourceAsStream("words.txt");
     BufferedReader reader = new BufferedReader(new 
InputStreamReader(inputStream));
-    String word;
-    while ((word = reader.readLine()) != null) {
-      words.add(word.trim());
+    try {
+      String word;
+      while ((word = reader.readLine()) != null) {
+        words.add(word.trim());
+      }
+    } finally {
+      reader.close();
     }
-    reader.close();
   }
 
   protected static RecordMutation getRecordMutation(int numberOfColumns, int 
numberOfFamilies, int numberOfWords) {

Reply via email to