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

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

    XMLWordPrintable

    Details

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

      Description

      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.  

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: