[JAVA-2291] Driver does not shutdown gracefully if maxConnectionIdleTime or maxConnectionLifeTime is set Created: 29/Aug/16  Updated: 02/Sep/16  Resolved: 02/Sep/16

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.12.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dmitry Ryabtsev Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-2052 Ensure that all threads created by De... Closed
Related

 Description   

The sample code that reproduces the problem:

1
import java.util.ArrayList;
2
import java.util.List;
3
import com.mongodb.MongoClient;
4
import com.mongodb.MongoClientOptions;
5
import com.mongodb.ReadPreference;
6
import com.mongodb.ServerAddress;
7
 
8
public class Test {
9
	public static void main(String[] args) {
10
		System.out.println("starting!!!");
11
		Test.test();
12
		System.out.println("end!!!");
13
	}
14
 
15
	public static void test(){
16
		MongoClient mongoClient = null;
17
		MongoClientOptions options = null;
18
		List<ServerAddress> serverList = null;
19
		try {
20
			serverList = new ArrayList<ServerAddress>();
21
        		serverList.add(new ServerAddress("localhost"));
22
			options = new MongoClientOptions.Builder().readPreference(ReadPreference.secondary())
23
					.maxConnectionIdleTime(1)
24
					.maxConnectionLifeTime(1)
25
					.build();
26
	    	mongoClient = new MongoClient (serverList, options);
27
		} catch (Exception exception) {
28
			exception.printStackTrace();
29
		}
30
 
31
	}
32
}

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.



 Comments   
Comment by Jeffrey Yemin [ 29/Aug/16 ]

Duplicates JAVA-2052, which was fixed in the 3.2.1 release.

Generated at Thu Feb 08 08:56:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.