[
https://issues.apache.org/jira/browse/TINKERPOP-2926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17718387#comment-17718387
]
Cole Greer commented on TINKERPOP-2926:
---------------------------------------
PR with resolution: [https://github.com/apache/tinkerpop/pull/2028]
> Gremlin-Java > An UnsupportedOperationException occurs on calling next()
> after a merge step with the option step modulator if the element does not
> exist
> --------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: TINKERPOP-2926
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2926
> Project: TinkerPop
> Issue Type: Bug
> Components: driver
> Affects Versions: 3.6.2
> Reporter: Andrew Kirk
> Assignee: Valentyn Kahamlyk
> Priority: Blocker
> Fix For: 3.7.0, 3.6.3
>
> Attachments: MergeTestApp.java
>
>
> Using Gremlin-Java, when the option step modulator is used in combination
> with a merge step, an `UnsupportedOperationException` is thrown upon calling
> `next()` if the specified element does not already exist.
> Using an example from the docs, the following construct works fine in the
> console if the element does not already exist:
> {code:groovy}
> gremlin> g.mergeV([(T.id):300]).
> option(Merge.onCreate,[(T.label):'Dog', name:'Toby', age:10]).
> option(Merge.onMatch,[age:11])
> {code}
> But, if we try to do the same thing in Java, we'll get an exception:
> {code:java}
> g.mergeV(Map.of(T.id, 300))
> .option(
> Merge.onCreate,
> Map.of(
> T.label, "Dog",
> "name", "Toby",
> "age", 10
> )
> )
> .option(
> Merge.onMatch,
> Map.of("age", 11)
> )
> .next();
> {code}
> Exception:
> {noformat}
> Exception in thread "main" java.lang.UnsupportedOperationException
> at
> java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
> at
> java.base/java.util.ImmutableCollections$AbstractImmutableMap.putAll(ImmutableCollections.java:1073)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeVertexStep.onCreateMap(MergeVertexStep.java:205)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeVertexStep.flatMap(MergeVertexStep.java:168)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:49)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeStep.processNextStart(MergeStep.java:165)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:135)
> at
> org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:40)
> at
> org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:249)
> at
> io.integralla.tinkerpop.poc.MergeWithOption.main(MergeWithOption.java:44)
> {noformat}
> If the element is first added (via an add or merge step), the merge with
> option works as expected.
> A full example is provided in the attached MergeTestApp.java
--
This message was sent by Atlassian Jira
(v8.20.10#820010)