Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3754

Stray monitor thread left behind if authentication fails

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 3.8.2, 3.12.5
    • Connection Management
    • None
    • MacOS

    Description

      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 }

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            gaurav-hevo Gaurav Bahrani
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: