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

Stray monitor thread left behind if authentication fails

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.8.2, 3.12.5
    • Component/s: Connection Management
    • Labels:
      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 }

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

              Created:
              Updated:
              Resolved: