Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2293

Collection caching in DBApiLayer.doGetCollection(…) is broken

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.3.0
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      DBApiLayer.doGetCollection(…) looks up DBCollection items from a cache based on name. However, DBCollection exposes methods to mutate the state of the returned instance which makes those state changes propagate to other (potentially concurrent) clients requesting a collection.

      In practice that means that a client e.g. setting a read preference on the collection, is setting it globally for all other clients that want to work with the same collection, although they might want to use a different read preference.

      The client side workaround is effectively synchronizing the access to a collection and making sure all mutable properties are always set.

      The original issue popped up with Spring Data MongoDB users that wanted to use different read preferences with different MongoTemplate instance.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            oliver.gierke Oliver Gierke
            None
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: