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

retryWrites URI option doesn't override MongoClientOptions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.9.0
    • Affects Version/s: None
    • Component/s: Configuration
    • None
    • Minor Change

      When .retryWrites(true) is specified in the MongoClientOptions builder, passing retryWrites=false in the connection string URI doesn't disable retryable writes.

      The bug appears to be that retryWrites are only set in the builder when retryWrites in the URI is set to true: https://github.com/mongodb/mongo-java-driver/blob/05d983e0e215a2e153129a5f61f81068329ff19a/driver-legacy/src/main/com/mongodb/MongoClientURI.java#L330

      if (proxied.getRetryWrites()) {
          builder.retryWrites(proxied.getRetryWrites());
      }
      

      This code should instead set the builder retryWrites if retryWrites has been set at all in proxied (like how all the other options are handled), rather than only if it has been set to a true value.

      Update

      This bug manifests similarly if the application sets .retryWrites(true) is specified in the MongoClientOptions builder and doesn't specify retryWrites at all in the connection string. In this case the final value will be false rather than true.

      Note also that this manifests as a similar bug in the new com.mongodb.MongoClientSettings class, and should be fixed there as well.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: