Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2926

Gremlin-Java > An UnsupportedOperationException occurs on calling next() after a merge step with the option step modulator if the element does not exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 3.6.2
    • 3.7.0, 3.6.3
    • driver
    • None

    Description

      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:

      gremlin> g.mergeV([(T.id):300]). 
        option(Merge.onCreate,[(T.label):'Dog', name:'Toby', age:10]).
        option(Merge.onMatch,[age:11])
      

      But, if we try to do the same thing in Java, we'll get an exception:

      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();
      

      Exception:

      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)
      

      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

      Attachments

        1. MergeTestApp.java
          2 kB
          Andrew Kirk

        Activity

          People

            valentyn Valentyn Kahamlyk
            integralla Andrew Kirk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: