Skip to content

Commit bce6bd6

Browse files
committed
Polish
1 parent 7b5df36 commit bce6bd6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import java.net.UnknownHostException;
2020
import java.util.ArrayList;
21-
import java.util.Arrays;
21+
import java.util.Collections;
2222
import java.util.List;
2323

2424
import com.mongodb.MongoClient;
@@ -209,7 +209,7 @@ public MongoClient createMongoClient(MongoClientOptions options,
209209
}
210210
String host = this.host == null ? "localhost" : this.host;
211211
int port = determinePort(environment);
212-
return new MongoClient(Arrays.asList(new ServerAddress(host, port)),
212+
return new MongoClient(Collections.singletonList(new ServerAddress(host, port)),
213213
credentials, options);
214214
}
215215
// The options and credentials are in the URI

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public void clientExists() {
5757
assertThat(this.context.getBeanNamesForType(Mongo.class).length).isEqualTo(1);
5858
}
5959

60-
@SuppressWarnings("deprecation")
6160
@Test
6261
public void optionsAdded() {
6362
this.context = new AnnotationConfigApplicationContext();
@@ -66,11 +65,10 @@ public void optionsAdded() {
6665
this.context.register(OptionsConfig.class,
6766
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
6867
this.context.refresh();
69-
assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout())
70-
.isEqualTo(300);
68+
assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions()
69+
.getSocketTimeout()).isEqualTo(300);
7170
}
7271

73-
@SuppressWarnings("deprecation")
7472
@Test
7573
public void optionsAddedButNoHost() {
7674
this.context = new AnnotationConfigApplicationContext();
@@ -79,8 +77,8 @@ public void optionsAddedButNoHost() {
7977
this.context.register(OptionsConfig.class,
8078
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
8179
this.context.refresh();
82-
assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout())
83-
.isEqualTo(300);
80+
assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions()
81+
.getSocketTimeout()).isEqualTo(300);
8482
}
8583

8684
@Test

0 commit comments

Comments
 (0)