Github user okram commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/521#discussion_r94776952
  
    --- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
 ---
    @@ -254,9 +254,14 @@ public default void forEachRemaining(final Consumer<? 
super E> action) {
             }
         }
     
    +    /**
    +     * Releases resources opened in any steps that implement {@link 
AutoCloseable}.
    +     */
         @Override
         public default void close() throws Exception {
    --- End diff --
    
    This is bad. `Steps` that are `TraversalParents` are responsible for 
propagating operations on them to those below. I would do the following:
    
    ```
    for(final Step<?,?> step : this.getSteps()) {
      if(step instanceof AutoCloseable)
        step.close();
    }
    ```
    
    Next, I would have `TraversalParent`  extend `AutoCloseable` with its 
default `close()` method being:
    
    ```
    for(final Traversal.Admin<?,?> traversal : this.getLocalChildren()) {
      traversal.close()
    }
    
    for(final Traversal.Admin<?,? traversal: this.getGlobalChildren()) {
      traversal.close();
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to