Driver does not shutdown gracefully if maxConnectionIdleTime or maxConnectionLifeTime is set

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.12.5
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The sample code that reproduces the problem:

      import java.util.ArrayList;
      import java.util.List;
      import com.mongodb.MongoClient;
      import com.mongodb.MongoClientOptions;
      import com.mongodb.ReadPreference;
      import com.mongodb.ServerAddress;
      
      public class Test {
      	public static void main(String[] args) {
      		System.out.println("starting!!!");
      		Test.test();
      		System.out.println("end!!!");
      	}
      
      	public static void test(){
      		MongoClient mongoClient = null;
      		MongoClientOptions options = null;
      		List<ServerAddress> serverList = null;
      		try {
      			serverList = new ArrayList<ServerAddress>();
              		serverList.add(new ServerAddress("localhost"));
      			options = new MongoClientOptions.Builder().readPreference(ReadPreference.secondary())
      					.maxConnectionIdleTime(1)
      					.maxConnectionLifeTime(1)
      					.build();
      	    	mongoClient = new MongoClient (serverList, options);
      		} catch (Exception exception) {
      			exception.printStackTrace();
      		}
      
      	}
      }
      

      If the highlighted lines are commented out, the process quits as soon as the "end!!!" line is printed. If the lines are present, the java process stays running.

      Works fine with v3.3.0, but fails with older version.

            Assignee:
            Unassigned
            Reporter:
            Dmitry Ryabtsev
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: