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

Add the ability to distinguish between an explicit write concern of {w : 1} and an acknowledged write concern that means to use the server's default

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0
    • Affects Version/s: 3.0.3, 2.13.3
    • Component/s: Write Operations
    • None

      The driver should add the ability to distinguish between an explicit write concern of

      {w : 1}

      and an acknowledged write concern that means to use the server's default. MongoClient instances by default should use the latter, as per specification.

      This can be done with a small backwards breaking change. We can add a no-argument constructor to WriteConcern which means "this is acknowledged but it should use the server's default configured write concern. And then we can change the declaration of WriteConcern.ACKNOWLEDGED to:

      public final static WriteConcern ACKNOWLEDGED = new WriteConcern();
      

      The only breakage is that with this change, the following code

          WriteConcern.ACKNOWLEDGED.getW()    // getW() returns an integer
      

      will throw an exception, since w will be null rather that an integer.

      In addition, the driver should add additional constants to WriteConcern, e.g.

      public final static WriteConcern W1 = new WriteConcern(1);
      public final static WriteConcern W2 = new WriteConcern(2);
      public final static WriteConcern W3 = new WriteConcern(3);
      

            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: