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

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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8.1
    • Affects Version/s: 3.8.0
    • Component/s: Write Operations
    • Labels:
      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@mongodb.com Ross Lawley
            Reporter:
            smachnowski@vocabulary.com Stephen Machnowski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: