diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 7c8522e5e66..64d2c81bca3 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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. diff --git a/docs/src/upgrade/release-3.6.x.asciidoc b/docs/src/upgrade/release-3.6.x.asciidoc index 39074ede26d..da190bdc89a 100644 --- a/docs/src/upgrade/release-3.6.x.asciidoc +++ b/docs/src/upgrade/release-3.6.x.asciidoc @@ -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 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs index 191b7a82933..aadaa16ab61 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -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; } ///