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

Repeated connection with expected authentication errors is not deterministic

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.13.1
    • Component/s: None
    • Labels:
      None

      I found the following problem

      // Mongo client with credentials on a non existing user
      // we expect an auth failure error
      MongoClient mongo = ...;
      try {
          // this will raise an auth failure exception
          mongo.getDatabaseNames().contains( databaseName );
      }
      catch (MongoException me) {
          // auth failure exception, that's cool
      }
      
      try {
          // we try again to connect with the same credentials
          // we should get an auth failure
          db.collectionExists( "WeDoNotCareWhatItIsWeNeedToConnect" );
      }
      catch (MongoException me) {
          if ( me.getCode() == 18 ) { //AUTHENTICATION_FAILED_CODE
              System.out.println("Auth failure");
          }
          if ( me instanceof MongoTimeoutException ) {
              System.out.println("Timeout failure");
          }
      }
      

      This code without the thread sleep will raise a timeout exception. With the thread sleep (or with a debug/break point enforced), I get the expected auth failure.
      Some kind of race condition is going on during the second connection attempt.

      Retrying twice (i.e. on the third attempt to do db.collectionExists( "WeDoNotCareWhatItIsWeNeedToConnect" ); it works.

      It might be related to JAVA-1780 but I don't know much about it. And trying the latest 2.13.2-SNAPSHOT did nto fix the issue

            Assignee:
            Unassigned Unassigned
            Reporter:
            emmanuelbernard Emmanuel Bernard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: