You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2021/06/17 18:21:46 UTC

[tinkerpop] 01/01: TINKERPOP-2568 Pushed the Graph instance into child traverals during application.

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2568
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 61af1fc03a651a83ea56dcf13eb518d89992cc91
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Thu Jun 17 14:17:47 2021 -0400

    TINKERPOP-2568 Pushed the Graph instance into child traverals during application.
    
    This should have been there at 3.5.0 but we didn't have tests to enforce the behavior. We have those tests now though so it will be enforced going forward.
---
 CHANGELOG.asciidoc                                                | 1 +
 .../gremlin/process/traversal/util/DefaultTraversal.java          | 8 +++++++-
 .../traversal/strategy/decoration/EventStrategyProcessTest.java   | 1 -
 .../tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java  | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 1798024..b811016 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 This release also includes changes from <<release-3-4-12, 3.4.12>>.
 
 * Fixed bug in Javascript error message related to validating anonymous traversal spawns.
+* Fixed bug where the `Graph` instance was not being assigned to child traversals.
 * Removed sending of deprecated session close message from Gremlin.Net driver.
 
 [[release-3-5-0]]
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index ea5cb33..b4b83ae 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -132,6 +132,13 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         // steps get reId'd and traverser requirements are set.
         if (isRoot() || this.getParent() instanceof VertexProgramStep) {
 
+            // prepare the traversal and all its children for strategy application
+            TraversalHelper.applyTraversalRecursively(t -> {
+                if (hasGraph) t.setGraph(this.graph);
+                t.setStrategies(this.strategies);
+                t.setSideEffects(this.sideEffects);
+            }, this);
+
             // note that prior to applying strategies to children we used to set side-effects and strategies of all
             // children to that of the parent. under this revised model of strategy application from TINKERPOP-1568
             // it doesn't appear to be necessary to do that (at least from the perspective of the test suite). by,
@@ -148,7 +155,6 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
             TraversalHelper.applyTraversalRecursively(t -> {
                 if (hasGraph) t.setGraph(this.graph);
                 if(!(t.isRoot()) && t != this && !t.isLocked()) {
-                    t.setStrategies(new DefaultTraversalStrategies());
                     t.setSideEffects(this.sideEffects);
                     t.applyStrategies();
                 }
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
index b648730..5aa9823 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
@@ -1964,7 +1964,6 @@ public class EventStrategyProcessTest extends AbstractGremlinProcessTest {
 
     @Test
     @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
-    @org.junit.Ignore("TINKERPOP-2579")
     public void shouldTriggerAddVertexAndPropertyUpdateWithCoalescePattern() {
         final StubMutationListener listener1 = new StubMutationListener();
         final StubMutationListener listener2 = new StubMutationListener();
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index b78dfc1..a6611bd 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -865,7 +865,7 @@ public class TinkerGraphTest {
         final GraphTraversalSource g = traversal().withEmbedded(graph).withStrategies(new TraversalStrategy.ProviderOptimizationStrategy() {
             @Override
             public void apply(final Traversal.Admin<?, ?> traversal) {
-                final Graph graph = TraversalHelper.getRootTraversal(traversal).getGraph().get();
+                final Graph graph = traversal.getGraph().get();
                 graph.addVertex("person");
             }
         });