You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2020/03/25 15:30:26 UTC

[tinkerpop] branch TINKERPOP-2350-dotnet created (now 1178d1c)

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

florianhockmann pushed a change to branch TINKERPOP-2350-dotnet
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


      at 1178d1c  TINKERPOP-2350 Fixed bug in GraphTraversal.Clone() in Gremln.Net

This branch includes the following new commits:

     new 1178d1c  TINKERPOP-2350 Fixed bug in GraphTraversal.Clone() in Gremln.Net

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[tinkerpop] 01/01: TINKERPOP-2350 Fixed bug in GraphTraversal.Clone() in Gremln.Net

Posted by fl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1178d1cba1797aeb4b4fa492ef2b1a70a16d6906
Author: Florian Hockmann <fh...@florian-hockmann.de>
AuthorDate: Wed Mar 25 16:27:27 2020 +0100

    TINKERPOP-2350 Fixed bug in GraphTraversal.Clone() in Gremln.Net
    
    Needed to deep copy bytecode. This was exactly the same problem as for
    Python.
---
 CHANGELOG.asciidoc                                   |  2 +-
 gremlin-dotnet/glv/GraphTraversal.template           |  2 +-
 .../Gremlin.Net/Process/Traversal/GraphTraversal.cs  |  2 +-
 .../Process/Traversal/GraphTraversalSourceTests.cs   | 20 ++++++++++++++++++++
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e0c512e..ab917e4 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,7 +29,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added `maxWaitForClose` configuration option to the Java driver.
 * Deprecated `maxWaitForSessionClose` in the Java driver.
 * Remove invalid service descriptors from gremlin-shaded.
-* Fixed bug in Python traversal `clone()` where deep copies of bytecode were not occurring.
+* Fixed bug in Python and .NET traversal `clone()` where deep copies of bytecode were not occurring.
 
 [[release-3-3-10]]
 === TinkerPop 3.3.10 (Release Date: February 3, 2020)
diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template
index a8d4466..430968d 100644
--- a/gremlin-dotnet/glv/GraphTraversal.template
+++ b/gremlin-dotnet/glv/GraphTraversal.template
@@ -86,7 +86,7 @@ namespace Gremlin.Net.Process.Traversal
         /// </summary>
         public GraphTraversal<S, E> Clone()
         {
-            return new GraphTraversal<S, E>(this.TraversalStrategies, this.Bytecode);
+            return new GraphTraversal<S, E>(TraversalStrategies, new Bytecode(Bytecode));
         }
     }
 }
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 910c6e8..1240ee0 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -1683,7 +1683,7 @@ namespace Gremlin.Net.Process.Traversal
         /// </summary>
         public GraphTraversal<S, E> Clone()
         {
-            return new GraphTraversal<S, E>(this.TraversalStrategies, this.Bytecode);
+            return new GraphTraversal<S, E>(TraversalStrategies, new Bytecode(Bytecode));
         }
     }
 }
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
index 9ae6cb5..b3c285f 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
@@ -63,5 +63,25 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
             Assert.Equal(0, gLocal.TraversalStrategies.Count);
             Assert.Equal(1, gRemote.TraversalStrategies.Count);
         }
+
+        [Fact]
+        public void CloneShouldCreateIndependentGraphTraversalModifiyingBytecode()
+        {
+            var g = AnonymousTraversalSource.Traversal();
+            var original = g.V().Out("created");
+            var clone = original.Clone().Out("knows");
+            var cloneClone = clone.Clone().Out("created");
+            
+            Assert.Equal(2, original.Bytecode.StepInstructions.Count);
+            Assert.Equal(3, clone.Bytecode.StepInstructions.Count);
+            Assert.Equal(4, cloneClone.Bytecode.StepInstructions.Count);
+
+            original.Has("person", "name", "marko");
+            clone.V().Out();
+            
+            Assert.Equal(3, original.Bytecode.StepInstructions.Count);
+            Assert.Equal(5, clone.Bytecode.StepInstructions.Count);
+            Assert.Equal(4, cloneClone.Bytecode.StepInstructions.Count);
+        }
     }
 }
\ No newline at end of file