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

TINKERPOP-3029 Fix enumeration for .NET 8 #2424

Merged
merged 1 commit into from
Jan 15, 2024
Merged
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 @@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
[[release-3-6-7]]
=== TinkerPop 3.6.7 (NOT OFFICIALLY RELEASED YET)

* Fixed a bug in Gremlin.Net for .NET 8 that led to exceptions: `InvalidOperationException: Enumeration has not started. Call MoveNext.`
* Improved error message from `JavaTranslator` by including exception source.
* Added missing `short` serialization (`gx:Int16`) to GraphSONV2 and GraphSONV3 in `gremlin-python`
* Added tests for error handling for GLV's if tx.commit() is called remotely for graphs without transactions support.
Expand Down
12 changes: 12 additions & 0 deletions docs/src/upgrade/release-3.6.x.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ complete list of all the modifications that are part of this release.

=== Upgrading for Users

==== Gremlin.Net: Fixed a bug in traversal enumeration on .NET 8

The behavior of `IEnumerable` was changed in .NET 8 when `Current` was accessed on it before starting the enumeration
via `MoveNext()`.
The Gremlin.Net driver unfortunately did exactly that in some cases which led to exceptions
(`InvalidOperationException: Enumeration has not started. Call MoveNext.`) on .NET 8 for some traversals.
Traversal enumeration has been changed for this version of Gremlin.Net to avoid this problem.

Older platforms than .NET 8 are not affected as `IEnumerable.Current` returned `null` there which is what the
Gremlin.Net driver expected.

See: link:https://issues.apache.org/jira/browse/TINKERPOP-3029[TINKERPOP-3029]

=== Upgrading for Providers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,22 @@ public bool MoveNext()
}

private bool MoveNextInternal()
{
{
if (_fetchedNext) return _nextAvailable;

if (!_nextAvailable || TraverserEnumerator.Current?.Bulk == 0)
{
_nextAvailable = TraverserEnumerator.MoveNext();
}
if (!_nextAvailable) return false;

var currentTraverser = TraverserEnumerator.Current;
if (currentTraverser?.Bulk > 1)
if (currentTraverser?.Bulk >= 1)
{
currentTraverser.Bulk--;
_nextAvailable = true;
}
else
{
_nextAvailable = TraverserEnumerator.MoveNext();
}

return _nextAvailable;
return true;
}

/// <summary>
Expand Down
Loading