File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
java/src/main/java/com/start Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 2222import com .mongodb .client .MongoDatabase ;
2323
2424public class Connection {
25-
2625 public static void main (String [] args ) throws ParseException {
2726 Options options = new Options ();
2827 options .addOption ("uri" , true , "MongoDB connection string." ); // hasArg is true by default
@@ -36,14 +35,14 @@ public static void main(String[] args) throws ParseException {
3635
3736 if (cmd .hasOption ("strict" )) {
3837 ServerApi serverApi = ServerApi .builder ()
39- .version (ServerApiVersion .V1 )
40- .strict (true )
41- .build ();
38+ .version (ServerApiVersion .V1 )
39+ .strict (true )
40+ .build ();
4241
4342 MongoClientSettings settings = MongoClientSettings .builder ()
44- .applyConnectionString (new ConnectionString (uri ))
45- .serverApi (serverApi )
46- .build ();
43+ .applyConnectionString (new ConnectionString (uri ))
44+ .serverApi (serverApi )
45+ .build ();
4746
4847 mongoClient = MongoClients .create (settings );
4948 } else {
@@ -75,5 +74,9 @@ public static void main(String[] args) throws ParseException {
7574 assert actual .equals (new Document ("_id" , 4 ).append ("a" , 4 )) : "Value should be 4" ;
7675
7776 mongoClient .close ();
77+
78+ // quick way to kill driver's background threads
79+ // and prevent hanging for a long time
80+ System .exit (0 );
7881 }
7982}
You can’t perform that action at this time.
0 commit comments