-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Reactive Streams
-
None
-
None
-
Java Drivers
-
None
-
None
-
None
-
None
-
None
-
None
The following test passes when callFirst is false, and hangs when it is true:
@ParameterizedTest
@ValueSource(booleans = {false, true})
void commandOptionIsSeparateForSeparateSubscriptions(final boolean callFirst)
throws Exception {
TestCommandListener commandListener = new TestCommandListener();
try (com.mongodb.reactivestreams.client.MongoClient client = MongoClients.create(Fixture.getMongoClientSettingsBuilder()
.addCommandListener(commandListener)
.build())) {
MongoDatabase database = client.getDatabase("db");
database.drop();
ChangeStreamPublisher<Document> publisher = database.getCollection("coll").watch();
if (callFirst) {
Mono.from(publisher.first()).subscribe().dispose();
} else {
Mono.from(publisher).subscribe().dispose();
}
commandListener.waitForEvents(CommandStartedEvent.class, event -> event.getCommandName().equals("killCursors"), 1);
assertNotNull(commandListener.getCommandStartedEvent("killCursors"));
}
}
That happens because BatchCursorPublisher.first handles only termination (via doOnTerminate), and does not handle cancellation.