Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-3029

Gremlin.Net: Traversal enumeration fails on .NET 8

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.5.8, 3.6.6, 3.7.1
    • 3.6.7, 3.7.2
    • dotnet
    • None

    Description

      This has been reported by Eric Sites on the dev mailing list: https://lists.apache.org/thread/snztwgk3s18h83mx8ql455hmx6ncl2r4


      I am having a lot of issues using the Gremlin.Net driver version 3.7.1 with .Net 8.

      It is almost entirely unusable.

      Any request that uses an Iterator throws an exception (MoveNext, Next, Iterate).
      System.InvalidOperationException: Enumeration has not started. Call MoveNext.

      Tracked it down to a change in .Net 8 IEnumerable<T>.Current behavior. Here is an issue about this filed in dotnet runtime:
      https://github.com/dotnet/runtime/issues/85243

      New bad code:

      var enumerator = saves.GetEnumerator();
      while (enumerator.Current == null) // <- Throws exception now
      {
         if (!enumerator.MoveNext())
            return list;
      }
      

      Should be changed to something like this:

      while (enumerator.MoveNext())
      {
          var item = enumerator.Current;
      }
      

      Here is an example of the issue in the Gremlin.Net code:
      https://github.com/apache/tinkerpop/blob/e8b9532fc0ec811460e97ebf5e00b8b9ec9192ac/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs#L132

      private object? GetCurrent()
      {
          // Use dynamic to object to prevent runtime dynamic conversion evaluation
          return TraverserEnumerator.Current?.Object;
      }
      

      Attachments

        Activity

          People

            Florian Hockmann Florian Hockmann
            Florian Hockmann Florian Hockmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: