diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index 0792fe5c62..95b8471c73 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java @@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.mongo; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.mongodb.MongoClient; @@ -209,7 +209,7 @@ public class MongoProperties { } String host = this.host == null ? "localhost" : this.host; int port = determinePort(environment); - return new MongoClient(Arrays.asList(new ServerAddress(host, port)), + return new MongoClient(Collections.singletonList(new ServerAddress(host, port)), credentials, options); } // The options and credentials are in the URI diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java index ff613330b3..d63b8575ba 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java @@ -57,7 +57,6 @@ public class MongoAutoConfigurationTests { assertThat(this.context.getBeanNamesForType(Mongo.class).length).isEqualTo(1); } - @SuppressWarnings("deprecation") @Test public void optionsAdded() { this.context = new AnnotationConfigApplicationContext(); @@ -66,11 +65,10 @@ public class MongoAutoConfigurationTests { this.context.register(OptionsConfig.class, PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class); this.context.refresh(); - assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout()) - .isEqualTo(300); + assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions() + .getSocketTimeout()).isEqualTo(300); } - @SuppressWarnings("deprecation") @Test public void optionsAddedButNoHost() { this.context = new AnnotationConfigApplicationContext(); @@ -79,8 +77,8 @@ public class MongoAutoConfigurationTests { this.context.register(OptionsConfig.class, PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class); this.context.refresh(); - assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout()) - .isEqualTo(300); + assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions() + .getSocketTimeout()).isEqualTo(300); } @Test