Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with DotNet 8 when a traverser is empty #2738

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ public bool HasNext()
/// </summary>
/// <returns>The result.</returns>
public E Next()
{
MoveNext();
return Current;
{
return MoveNext() ? Current : default;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ public void ShouldDrainAllTraversersWhenIterateIsCalled()

Assert.Null(drainedTraversal.Next());
}

[Fact]
public void ShouldReturnNullWhenTraverserIsEmpty()
{
var someObjs = new List<object?>();
var traversal = new TestTraversal(someObjs);

var emptyTraversal = traversal.Iterate();

Assert.Null(emptyTraversal.Next());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if returning null is the more proper behavior. Iterate() is called on the Traversal which will move to the end of the enumerator. Then Next() is called which I think would be reasonable to throw an exception.

}

[Fact]
public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable()
Expand Down
Loading