Browse Source

Propagate retryWrites flag from connection URI to ReactiveMongoClient

Closes gh-14032
pull/14085/head
Nikolay Rybak 7 years ago committed by Andy Wilkinson
parent
commit
7759dcd9df
  1. 1
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java
  2. 8
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java

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

@ -159,6 +159,7 @@ public class ReactiveMongoClientFactory { @@ -159,6 +159,7 @@ public class ReactiveMongoClientFactory {
if (connection.getApplicationName() != null) {
builder.applicationName(connection.getApplicationName());
}
builder.retryWrites(connection.getRetryWrites());
return builder;
}

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

@ -112,6 +112,14 @@ public class ReactiveMongoClientFactoryTests { @@ -112,6 +112,14 @@ public class ReactiveMongoClientFactoryTests {
assertMongoCredential(credential, "user", "secret", "test");
}
@Test
public void retryWritesIsPropagatedFromUri() {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://localhost/test?retryWrites=true");
MongoClient client = createMongoClient(properties);
assertThat(client.getSettings().getRetryWrites()).isTrue();
}
@Test
public void uriCannotBeSetWithCredentials() {
MongoProperties properties = new MongoProperties();

Loading…
Cancel
Save