You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/02/04 18:17:36 UTC

[07/12] lucene-solr git commit: LUCENE-7011: use try-w-resources

LUCENE-7011: use try-w-resources


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3a889301
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3a889301
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3a889301

Branch: refs/heads/lucene-6835
Commit: 3a889301c7436f679eacfe8baedab30e7cce0522
Parents: c6ec006
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Feb 3 10:19:26 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Feb 3 10:19:26 2016 -0500

----------------------------------------------------------------------
 .../simpletext/SimpleTextPointWriter.java       | 37 ++++++++++----------
 1 file changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a889301/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
index 8d5f107..7f92ae8 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
@@ -67,7 +67,7 @@ class SimpleTextPointWriter extends PointWriter {
   public void writeField(FieldInfo fieldInfo, PointReader values) throws IOException {
 
     // We use the normal BKDWriter, but subclass to customize how it writes the index and blocks to disk:
-    BKDWriter writer = new BKDWriter(writeState.directory,
+    try (BKDWriter writer = new BKDWriter(writeState.directory,
                                      writeState.segmentInfo.name,
                                      fieldInfo.getPointDimensionCount(),
                                      fieldInfo.getPointNumBytes(),
@@ -152,27 +152,28 @@ class SimpleTextPointWriter extends PointWriter {
           write(out, new BytesRef(bytes, 0, bytes.length).toString());
           newline(out);
         }          
-      };
+      }) {
 
-    values.intersect(fieldInfo.name, new IntersectVisitor() {
-        @Override
-        public void visit(int docID) {
-          throw new IllegalStateException();
-        }
+      values.intersect(fieldInfo.name, new IntersectVisitor() {
+          @Override
+          public void visit(int docID) {
+            throw new IllegalStateException();
+          }
 
-        public void visit(int docID, byte[] packedValue) throws IOException {
-          writer.add(packedValue, docID);
-        }
+          public void visit(int docID, byte[] packedValue) throws IOException {
+            writer.add(packedValue, docID);
+          }
 
-        @Override
-        public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
-          return Relation.CELL_CROSSES_QUERY;
-        }
-      });
+          @Override
+          public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
+            return Relation.CELL_CROSSES_QUERY;
+          }
+        });
 
-    // We could have 0 points on merge since all docs with points may be deleted:
-    if (writer.getPointCount() > 0) {
-      indexFPs.put(fieldInfo.name, writer.finish(dataOut));
+      // We could have 0 points on merge since all docs with points may be deleted:
+      if (writer.getPointCount() > 0) {
+        indexFPs.put(fieldInfo.name, writer.finish(dataOut));
+      }
     }
   }