[JAVA-3687] Observable.zip().head() often emits null Created: 20/Mar/20  Updated: 28/Oct/23  Resolved: 15/Apr/20

Status: Closed
Project: Java Driver
Component/s: API, Scala
Affects Version/s: 4.0.2
Fix Version/s: 4.0.3, 4.1.0

Type: Bug Priority: Major - P3
Reporter: Jeff Mather Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.  



 Comments   
Comment by Githook User [ 15/Apr/20 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: ZipObservable fix

JAVA-3687
Branch: 4.0.x
https://github.com/mongodb/mongo-java-driver/commit/7d35c2ce5addf9f0cd8671cd1f5706a7d5e360c2

Comment by Githook User [ 15/Apr/20 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: ZipObservable fix

JAVA-3687
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/a202e33e4bd81247242f0c6b8c5d479600a6c0e8

Comment by Ross Lawley [ 14/Apr/20 ]

PR: https://github.com/rozza/mongo-java-driver/pull/376

Generated at Thu Feb 08 09:00:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.