-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.8.0
-
Component/s: Write Operations
-
None
The following code throws a NullPointerException at com.mongodb.internal.connection.ProtocolHelper.getErrorCode(ProtocolHelper.java:183). It appears retryWrites needs to be disabled in order to use WriteConcern.UNACKNOWLEDGED for insert/update operations.
MongoClient mongoClient = MongoClients.create("mongodb://username:password@localhost:27017/?retryWrites=true"); MongoDatabase db = mongoClient.getDatabase("foo"); db.getCollection("bar").withWriteConcern(WriteConcern.UNACKNOWLEDGED).insertOne(new Document("_id", new ObjectId()));