Apply customize() to createCredentialNetworkMongoClient()
See gh-11376
This commit is contained in:
parent
601b5e4d9a
commit
90369996a9
|
@ -92,6 +92,10 @@ public class ReactiveMongoClientFactory {
|
|||
ClusterSettings clusterSettings = ClusterSettings.builder()
|
||||
.hosts(Collections.singletonList(new ServerAddress(host, port))).build();
|
||||
builder.clusterSettings(clusterSettings);
|
||||
return createMongoClient(builder);
|
||||
}
|
||||
|
||||
private MongoClient createMongoClient(Builder builder) {
|
||||
customize(builder);
|
||||
return MongoClients.create(builder.build());
|
||||
}
|
||||
|
@ -102,7 +106,7 @@ public class ReactiveMongoClientFactory {
|
|||
}
|
||||
ConnectionString connectionString = new ConnectionString(
|
||||
this.properties.determineUri());
|
||||
return MongoClients.create(createBuilder(settings, connectionString).build());
|
||||
return createMongoClient(createBuilder(settings, connectionString));
|
||||
}
|
||||
|
||||
private MongoClient createCredentialNetworkMongoClient(MongoClientSettings settings) {
|
||||
|
@ -117,7 +121,7 @@ public class ReactiveMongoClientFactory {
|
|||
ServerAddress serverAddress = new ServerAddress(host, port);
|
||||
builder.clusterSettings(ClusterSettings.builder()
|
||||
.hosts(Collections.singletonList(serverAddress)).build());
|
||||
return MongoClients.create(builder.build());
|
||||
return createMongoClient(builder);
|
||||
}
|
||||
|
||||
private void applyCredentials(Builder builder) {
|
||||
|
@ -155,7 +159,6 @@ public class ReactiveMongoClientFactory {
|
|||
if (connection.getApplicationName() != null) {
|
||||
builder.applicationName(connection.getApplicationName());
|
||||
}
|
||||
customize(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,16 @@ public class ReactiveMongoClientFactoryTests {
|
|||
verify(customizer).customize(any(MongoClientSettings.Builder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizerIsInvokedWhenHostIsSet() {
|
||||
MongoProperties properties = new MongoProperties();
|
||||
properties.setHost("localhost");
|
||||
MongoClientSettingsBuilderCustomizer customizer = mock(
|
||||
MongoClientSettingsBuilderCustomizer.class);
|
||||
createMongoClient(properties, this.environment, customizer);
|
||||
verify(customizer).customize(any(MongoClientSettings.Builder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizerIsInvokedForEmbeddedMongo() {
|
||||
MongoProperties properties = new MongoProperties();
|
||||
|
|
Loading…
Reference in New Issue