Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3687

Observable.zip().head() often emits null

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.3, 4.1.0
    • Affects Version/s: 4.0.2
    • Component/s: API, Scala
    • None

      I have this code stanza in a repository's fetchVideos() method:

      val find = collection.find(query).skip(numToSkip).limit(videosPerPage)
        .sort(ascending("title")).collect()
      val count = collection.countDocuments(query)
      val zip = find.zip(count)
      zip.head()

      It is intended to return a future containing a tuple of:

      • a subset of the Video objects in the database which match the given query filter
      • the total count of Video objects in the database which match the given query filter

      so, a 

      Future[(Seq[Video], Long)]

      to enable pagination of search results for videos.

      Instead, it often returns null as the future value.  Not always, but usually.  When null is not the future value, the result is often correct, though not always.

      I have since gone on to serialize the two database accesses using a flatMap(), and that works as expected, but it seems to me like a bug that the above parallelization of these accesses does not also work.  

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            jeff@reliantsoftwareeng.com Jeff Mather
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: