TINKERPOP-1589 Re-introduced CloseableIterator

https://issues.apache.org/jira/browse/TINKERPOP-1589
Add support for the closing of Iterators returned from
Vertex.vertices() and Vertex.edges().
Iterators are closed once they are read to completion.
Make FlatMapStep implement AutoCloseable in case iterator is not
read to completion, should get closed when Traversal is closed.
Remove unnecessary null check (null is never an instanceof).
OLTP mode support only. More extensive changes required for OLAP.
NOTE: Rethrowing checked Exception from close() as unchecked
RuntimeException in order to retain Step.reset() and
AbstractStep.processNextStart() signatured.
Fix bug in last commit where iterator is not set to
EMPTY_ITERATOR for iterators that are not Closeable.


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

Branch: refs/heads/TINKERPOP-1599
Commit: c2d183acf4418733666d1cd603f15a87beb9aa97
Parents: c8d5ff9
Author: PaulJackson123 <[email protected]>
Authored: Thu Jan 26 09:52:30 2017 -0500
Committer: PaulJackson123 <[email protected]>
Committed: Thu Jan 26 09:52:30 2017 -0500

----------------------------------------------------------------------
 .../process/traversal/step/map/FlatMapStep.java     | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2d183ac/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
index 7afdd40..ce79bdf 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
@@ -64,16 +64,16 @@ public abstract class FlatMapStep<S, E> extends 
AbstractStep<S, E> implements Au
     }
 
     private void closeIterator() {
-        if (this.iterator instanceof AutoCloseable) {
-            try {
+        try {
+            if (this.iterator instanceof AutoCloseable) {
                 ((AutoCloseable) this.iterator).close();
             }
-            catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-            finally {
-                this.iterator = EmptyIterator.instance();
-            }
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        finally {
+            this.iterator = EmptyIterator.instance();
         }
     }
 }

Reply via email to