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

Deprecate Mongo property mutators

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: None
    • Component/s: API
    • Labels:
      None

      Since MongoDatabase instances are immutable, it's quite confusing to have mutable Mongo/MongoClient properties that have no effect on MongoDatabase/MongoCollection instances. In particular,

      MongoClient client = new MongoClient();   // w : 1
      client.setWriteConcern(WriteConcern.REPLICA_ACKNOWLEDGED);
      MongoDatabase database = client.getDatabase();  // w : 1
      database.insertOne(new Document(...));   // still w : 1
      

      This is different than the behavior of the now-deprecated Mongo#getDB method.

      So we should document this, and at the same time deprecate the following methods on Mongo:

      • setReadPreference
      • setWriteConcern
      • setOptions
      • resetOptions
      • addOption
      • getOptions

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: