[ 
https://issues.apache.org/jira/browse/TINKERPOP-2408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Divij Vaidya updated TINKERPOP-2408:
------------------------------------
    Description: 
The iterator here should be closed in a finally block: 
https://github.com/apache/tinkerpop/blob/3.4.8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/HasContainer.java#L85
 

If the iterator is not closed, due to short circuit return, it could lead to 
open iterator leaks in the underlying storage.

The code should look like:

{code:java}
        try {
            while (itty.hasNext()) {
                if (testValue(itty.next()))
                    return true;
            }
        } finally {
            if (itty instanceof AutoCloseable) {
                ((AutoCloseable) itty).close();
            }
        }
{code}


  was:
The iterator here should be closed in a finally block: 
https://github.com/apache/tinkerpop/blob/3.4.8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/HasContainer.java#L85
 

If the iterator is not closed, due to short circuit return, it could lead to 
open iterator leaks in the underlying storage.

The code should look like:

{code:java}
        try {
            while (itty.hasNext()) {
                if (testValue(itty.next()))
                    return true;
            }
        } finally {
            if (itty instanceof AutoCloseable) {
                Code.wrapThrow(() -> ((AutoCloseable) itty).close());
            }
        }
{code}



> Iterator leak in HasContainer
> -----------------------------
>
>                 Key: TINKERPOP-2408
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2408
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.4.8
>            Reporter: Divij Vaidya
>            Priority: Minor
>
> The iterator here should be closed in a finally block: 
> https://github.com/apache/tinkerpop/blob/3.4.8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/HasContainer.java#L85
>  
> If the iterator is not closed, due to short circuit return, it could lead to 
> open iterator leaks in the underlying storage.
> The code should look like:
> {code:java}
>         try {
>             while (itty.hasNext()) {
>                 if (testValue(itty.next()))
>                     return true;
>             }
>         } finally {
>             if (itty instanceof AutoCloseable) {
>                 ((AutoCloseable) itty).close();
>             }
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to