I see that in Spring Data Mongo M3, MongoTemplate has a prepareCollection method. Default impl would set slaveOk on it (if requested on the MongoTemplate). From what I grok, the intent is to allow subclasses can do additional settings on the collection.

The problem I see with this is, DBCollection is cached by Mongo Java Driver. It creates one instance per VM for a collection name. So naturally any provisioning done on a DBCollection by multiple threads will behave unpredictably.

I would propose to change the API to say prepareCursor, and use DBCursors for all APIs which are request scoped.

Thoughts/opinions?