-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 5.1.4
-
Component/s: None
-
None
-
Java Drivers
Summary
Driver version 4.11.x failed the reactive stream with a `MongoCommandException` when creating a collection and getting a Publisher as response.
Driver version 5.1.x does neither publish a success (null void) nor an error to the stream it seems.
I figured out that when creating a non-capped collection, the MongoCommandException is still emitted into the stream, so this seems to have something to do with capped collections (or max documents 1).
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
How to Reproduce
With Apache Pekko as reactive API wrapper:
final CreateCollectionOptions collectionOptions = new CreateCollectionOptions().capped(true).sizeInBytes(cappedCollectionSizeInBytes).maxDocuments(1); Source.lazySource( () -> Source.fromPublisher(database.createCollection("foo", collectionOptions))) .mapMaterializedValue(whatever -> NotUsed.getInstance()) .map(nullValue -> Done.done()) .withAttributes(Attributes.inputBuffer(1, 1)) .recoverWithRetries(1, new PFBuilder<Throwable, Source<Done, NotUsed>>() .match(MongoCommandException.class, error.getErrorCode() == COLLECTION_ALREADY_EXISTS_ERROR_CODE, error -> Source.single(Done.done())) .build());
In the example, the lambda
error -> Source.single(Done.done()))
is never invoked.
When omitting the capped collection options, it is invoked when the collection already exists.
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.