-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.8.2, 3.12.5
-
Component/s: Connection Management
-
None
-
Environment:MacOS
If incorrect credentials are supplied while setting up connection to replica-set, it results in stray monitor thread left behind. Since 'mongoClient' never got set, caller can not call close() to force driver to release resources.
------
MongoCredential credential = MongoCredential.createCredential(dbUser, authDB, dbPassword.toCharArray()); // credentials supplied are incorrect
ServerAddress address = new ServerAddress(host, localPort);
MongoClientOptions options =
MongoClientOptions.builder()
.serverSelectionTimeout(serverSelectionTimeout)
.connectTimeout(connecTimeout)
.readPreference(ReadPreference.secondaryPreferred())
.sslEnabled(sslEnabled)
.sslInvalidHostNameAllowed(true)
.build();
try
{ MongoClient mongoClient = new MongoClient(address, credential, options); }catch (MongoSecurityException mse)
{ // handle login error }catch (MongoTimeoutException mte)
{ // handle timeout }catch (Exception ex)
{ // handle other errors }