-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Configuration
-
None
-
(copied to CRM)
-
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.