-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.12.5
-
Component/s: 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.
- duplicates
-
JAVA-2052 Ensure that all threads created by DefaultConnectionPool are daemons
- Closed