[ 
https://issues.apache.org/jira/browse/TINKERPOP-1468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15596415#comment-15596415
 ] 

Marko A. Rodriguez commented on TINKERPOP-1468:
-----------------------------------------------

This is really weird because there is no method signature that allows for no 
args.

{code}
    public default <E2> GraphTraversal<S, E2> optional(final Traversal<?, E2> 
optionalTraversal) {
        this.asAdmin().getBytecode().addStep(Symbols.optional, 
optionalTraversal);
        return this.asAdmin().addStep(new ChooseStep<>(this.asAdmin(), 
(Traversal.Admin<E, ?>) optionalTraversal, (Traversal.Admin<E, E2>) 
optionalTraversal.asAdmin().clone(), (Traversal.Admin<E, E2>) 
__.<E2>identity()));
    }

{code}

And its dying on the {{clone()}} call. I don't know why Groovy isn't throwing a 
"no such method found exception".

> GraphTraversal.optional throws a NPE if no traversal is provided
> ----------------------------------------------------------------
>
>                 Key: TINKERPOP-1468
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1468
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.2.2
>            Reporter: Ted Wilmes
>              Labels: trivial
>
> {{GraphTraversal.optional}} throws a NPE if no traversal is provided.  We 
> should probably throw a friendlier exception with instructions to provide a 
> traversal as an argument.
> {code}
> gremlin> g.V().optional()
> java.lang.NullPointerException
> Type ':help' or ':h' for help.
> Display stack trace? [yN]y
> java.lang.NullPointerException
>       at 
> org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.optional(GraphTraversal.java:1316)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to