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) {
102102 }
103103 Set <ServerAddress > hostsSet = new LinkedHashSet <ServerAddress >(hosts .size ());
104104 for (ServerAddress host : hosts ) {
105+ notNull ("host" , host );
105106 hostsSet .add (new ServerAddress (host .getHost (), host .getPort ()));
106107 }
107108 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 {
213213 thrown(IllegalArgumentException )
214214 }
215215
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+
216224 def ' should remove duplicate hosts' () {
217225 when :
218226 def settings = ClusterSettings . builder(). hosts([new ServerAddress (' server1' ),
You can’t perform that action at this time.
0 commit comments