MongoCollection.insertOne throws NullPointerException with WriteConcern.UNACKNOWLEDGED & retryWrites=true

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.8.1
    • Affects Version/s: 3.8.0
    • Component/s: Write Operations
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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()));
      

              Assignee:
              Ross Lawley
              Reporter:
              Stephen Machnowski
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: