diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5e4e61c5c6f..3ce7b007844 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -29,6 +29,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima * The default logging level for Gremlin Console in Windows is set to the same WARN level as for Linux. * Updated to Docker Compose V2 with `docker-compose` changed to `docker compose` in pom and script files. * Add command line option `-l` to change logging level for Gremlin Console in Windows. +* Fixed a bug with DotNet 8 when there are no results on a query. [[release-3-6-7]] === TinkerPop 3.6.7 (April 8, 2024) diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs index aadaa16ab61..00384d3c325 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -198,9 +198,8 @@ public bool HasNext() /// /// The result. public E Next() - { - MoveNext(); - return Current; + { + return MoveNext() ? Current : default; } /// diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs index 5f87dffd062..27644628d22 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs @@ -98,6 +98,17 @@ public void ShouldDrainAllTraversersWhenIterateIsCalled() Assert.Null(drainedTraversal.Next()); } + + [Fact] + public void ShouldReturnNullWhenTraverserIsEmpty() + { + var someObjs = new List(); + var traversal = new TestTraversal(someObjs); + + var emptyTraversal = traversal.Iterate(); + + Assert.Null(emptyTraversal.Next()); + } [Fact] public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable()