File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
main/com/mongodb/connection
test/unit/com/mongodb/connection Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ public Builder hosts(final List<ServerAddress> hosts) {
102
102
}
103
103
Set <ServerAddress > hostsSet = new LinkedHashSet <ServerAddress >(hosts .size ());
104
104
for (ServerAddress host : hosts ) {
105
+ notNull ("host" , host );
105
106
hostsSet .add (new ServerAddress (host .getHost (), host .getPort ()));
106
107
}
107
108
this .hosts = Collections .unmodifiableList (new ArrayList <ServerAddress >(hostsSet ));
Original file line number Diff line number Diff line change @@ -213,6 +213,14 @@ class ClusterSettingsSpecification extends Specification {
213
213
thrown(IllegalArgumentException )
214
214
}
215
215
216
+ def ' should throws if hosts list contains null value' () {
217
+ when :
218
+ ClusterSettings . builder(). hosts([null ]). build();
219
+
220
+ then :
221
+ thrown(IllegalArgumentException )
222
+ }
223
+
216
224
def ' should remove duplicate hosts' () {
217
225
when :
218
226
def settings = ClusterSettings . builder(). hosts([new ServerAddress (' server1' ),
You can’t perform that action at this time.
0 commit comments