Stray monitor thread left behind if authentication fails

XMLWordPrintableJSON

    • 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
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 }

              Assignee:
              Jeffrey Yemin
              Reporter:
              Gaurav Bahrani
              None
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: