[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 Created: 09/Sep/15  Updated: 07/Dec/15  Resolved: 09/Oct/15

Status: Closed
Project: Java Driver
Component/s: Write Operations
Affects Version/s: 3.0.3, 2.13.3
Fix Version/s: 3.2.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-131 Drivers should only send {w:1} if and... Closed

 Description   

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);



 Comments   
Comment by Jeffrey Yemin [ 07/Dec/15 ]

The 3.2.0 driver, which contains a fix for this issue, has been released today.

Comment by Githook User [ 09/Oct/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1955: Change semantics of WriteConcern.ACKNOWLEDGED to mean use server default instead of w = 1.

Also add new constants: WriteConcern.W1, WriteConcern.W2, WriteConcern.W3
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/956ded3c3b8b77a61265915241a82a38467f7784

Generated at Thu Feb 08 08:55:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.