Skip to content

Commit 140d544

Browse files
committed
Propagate retryWrites flag to ReactiveMongoClient
Add retryWrites flag to set of flags propagated from connection string to ReactiveMongoClient. Regular MongoClientFactory relies of MongoClientURI class that propagates all flags in its getOptions() method.
1 parent 718372e commit 140d544

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private Builder createBuilder(MongoClientSettings settings,
159159
if (connection.getApplicationName() != null) {
160160
builder.applicationName(connection.getApplicationName());
161161
}
162+
builder.retryWrites(connection.getRetryWrites());
162163
return builder;
163164
}
164165

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public void uriCanBeCustomized() {
112112
assertMongoCredential(credential, "user", "secret", "test");
113113
}
114114

115+
@Test
116+
public void retryWritesIsPropagatedFromUri() {
117+
MongoProperties properties = new MongoProperties();
118+
properties.setUri("mongodb://localhost/test?retryWrites=true");
119+
MongoClient client = createMongoClient(properties);
120+
assertThat(client.getSettings().getRetryWrites()).isTrue();
121+
}
122+
115123
@Test
116124
public void uriCannotBeSetWithCredentials() {
117125
MongoProperties properties = new MongoProperties();

0 commit comments

Comments
 (0)