From 2bad9c5ce537b798fa776882913255d6be1f5121 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Tue, 11 Jul 2023 10:20:22 +0100 Subject: [PATCH] Fix: MongoClientSettings.applyConnectionString retryReads bug Ensure that retryReads is copied. JAVA-5048 --- driver-core/src/main/com/mongodb/MongoClientSettings.java | 4 ++++ .../unit/com/mongodb/MongoClientSettingsSpecification.groovy | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/driver-core/src/main/com/mongodb/MongoClientSettings.java b/driver-core/src/main/com/mongodb/MongoClientSettings.java index a415a98954a..9f64f85cfa7 100644 --- a/driver-core/src/main/com/mongodb/MongoClientSettings.java +++ b/driver-core/src/main/com/mongodb/MongoClientSettings.java @@ -299,6 +299,10 @@ public Builder applyConnectionString(final ConnectionString connectionString) { if (retryWritesValue != null) { retryWrites = retryWritesValue; } + Boolean retryReadsValue = connectionString.getRetryReads(); + if (retryReadsValue != null) { + retryReads = retryReadsValue; + } if (connectionString.getUuidRepresentation() != null) { uuidRepresentation = connectionString.getUuidRepresentation(); } diff --git a/driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy b/driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy index db9938fcecf..4cbee308462 100644 --- a/driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy +++ b/driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy @@ -194,7 +194,7 @@ class MongoClientSettingsSpecification extends Specification { .readPreference(ReadPreference.secondary()) .writeConcern(WriteConcern.JOURNALED) .retryWrites(true) - .retryReads(false) + .retryReads(true) .readConcern(ReadConcern.LOCAL) .applicationName('app1') .addCommandListener(commandListener)