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

Deprecate Mongo property mutators

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.3.0
    • None
    • API
    • None

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: