Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mongodb autodiscover at connect when just one server is provided #2395

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[cygnus-ngsi] [mongo-sink] Add mongo_ssl, mongo_ssl_invalid_host_allowed, mongo_ssl_keystore_path_file, mongo_ssl_keystore_password, mongo_ssl_truststore_path_file and mongo_ssl_truststore_password options for mongoDB connections
[cygnus-common] [mongo-backend] Use sslEnabled, sslInvalidHostNameAllowed, sslKeystorePathFile, sslKeystorePassword, sslTruststorePathFile and sslTruststorePassword options for mongoDB connections
[cygnus-common] [mongo-backend] Allow mongodb autodiscover at connect when just one server is provided
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,17 @@ private MongoDatabase getDatabase(String dbName) {
.sslContext(sslContext)
.build();
}
client = new MongoClient(servers, credential, options);
if (servers.size() == 1) { // allow auto-discover when just one endpoint is provided
client = new MongoClient(servers.get(0), credential, options);
} else {
client = new MongoClient(servers, credential, options);
}
} else {
client = new MongoClient(servers, options);
if (servers.size() == 1) { // allow auto-discover when just one endpoint is provided
client = new MongoClient(servers.get(0), options);
} else {
client = new MongoClient(servers, options);
}
} // if else
} // if

Expand Down
Loading