[JAVA-2922] MongoCollection.insertOne throws NullPointerException with WriteConcern.UNACKNOWLEDGED & retryWrites=true Created: 07/Aug/18  Updated: 28/Oct/23  Resolved: 14/Aug/18

Status: Closed
Project: Java Driver
Component/s: Write Operations
Affects Version/s: 3.8.0
Fix Version/s: 3.8.1

Type: Bug Priority: Major - P3
Reporter: Stephen Machnowski Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File stacktrace.png    

 Description   

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



 Comments   
Comment by Githook User [ 17/Aug/18 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: Fix NPE with unacknowledged retryable bulk writes

JAVA-2922
Branch: 3.8.x
https://github.com/mongodb/mongo-java-driver/commit/f3fc596e138bd22b3785d6d628011613416357ff

Comment by Githook User [ 14/Aug/18 ]

Author:

{'username': 'rozza', 'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley'}

Message: Fix NPE with unacknowledged retryable bulk writes

JAVA-2922
Branch: 3.6.x
https://github.com/mongodb/mongo-java-driver/commit/8ac89235d6fae21d5ec0d86aaa30cf513f22dc5f

Comment by Githook User [ 14/Aug/18 ]

Author:

{'username': 'rozza', 'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley'}

Message: Fix NPE with unacknowledged retryable bulk writes

JAVA-2922
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1899b03bff4f55040fe7c868eb231f7eab3c15bd

Comment by Ross Lawley [ 08/Aug/18 ]

Thanks smachnowski@vocabulary.com for reporting this issue, this will be fixed in the next release.

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