diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 1e33bbc51..5100d2164 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -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 diff --git a/cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends/mongo/MongoBackendImpl.java b/cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends/mongo/MongoBackendImpl.java index d324e6b7a..d4021859d 100644 --- a/cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends/mongo/MongoBackendImpl.java +++ b/cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends/mongo/MongoBackendImpl.java @@ -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