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 <f...@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

Reply via email to