-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Cluster Management
-
Labels:None
Currently, when you try to connect to a remote MongoDB server, the connection will appear to be successful even though the remote server is down. The only indication is from the log messages but the Java API continues as normal.
To make a connection and then check the connection is successful then Java programs need do something similar to the following...
MongoClient mongoClient = new MongoClient();
mongoClient.getAddress();
I'd expect the first line to throw an exception if a connection to any server (in a server list say) failed but it doesn't so the second line is required in order to do it. Very annoying.
I propose that either an immediate MongoException is thrown by the MongoClient or you introduce a method where the connection can be tested (e.g. an isClosed or whatever method on the MongoClient class). Both would be good though. One for immediate connection problems and the other for subsequent checks by the application.