-
Type: Question
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 4.8.0
-
Component/s: None
-
None
Summary
When I run several async requests against Mongo and then cancel after receiving the first result, I get the error:
ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped reactor.core.Exceptions$ErrorCallbackNotImplemented: com.mongodb.MongoException: next() called after the cursor was closed. Caused by: com.mongodb.MongoException: next() called after the cursor was closed.
I am using Rx Java .firstElement() in order to cancel unwanted requests.
This is using...
driver version: 4.8.0
Mongo version: 6
Topology: replica set
How to Reproduce
I cannot provide exact steps to reproduce the database but the query below matches a couple of entries in the database which are indexed. This code triggers the exception every time.
Flowable.range(1, 200) .flatMapMaybe( iter -> Flowable.fromIterable(Vector.of(mainCollection, mainCollection)) .map( dataBaseName -> mongoClient.getDatabase(dataBaseName).getCollection(collectionName)) .flatMap(collection -> Flowable.fromPublisher(collection.find())) .firstElement()) .collect(Vector.collector()) .blockingGet();
Additional Background
It appears to be the double nesting of Flowables that helps trigger this bug. With a very large flat list of queries it doesn't trigger.