File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -291,9 +291,6 @@ private synchronized void ensureOpen(final Mongo mongo) throws IOException {
291291 _socket .setSoTimeout ( _options .socketTimeout );
292292 _in = new BufferedInputStream ( _socket .getInputStream () );
293293 _out = _socket .getOutputStream ();
294- if (mongo != null ) {
295- _serverVersion = getVersion (runCommand (mongo .getDB ("admin" ), new BasicDBObject ("buildinfo" , 1 )));
296- }
297294 successfullyConnected = true ;
298295 }
299296 catch ( IOException e ){
@@ -316,6 +313,22 @@ private synchronized void ensureOpen(final Mongo mongo) throws IOException {
316313 sleepTime *= 2 ;
317314 }
318315 } while (!successfullyConnected );
316+
317+ if (mongo != null ) {
318+ try {
319+ CommandResult buildInfoResult = runCommand (mongo .getDB ("admin" ), new BasicDBObject ("buildinfo" , 1 ));
320+ buildInfoResult .throwOnError ();
321+ _serverVersion = getVersion (buildInfoResult );
322+ }
323+ catch (IOException e ) {
324+ close ();
325+ throw e ;
326+ }
327+ catch (RuntimeException e ) {
328+ close ();
329+ throw e ;
330+ }
331+ }
319332 }
320333
321334 @ SuppressWarnings ("unchecked" )
You can’t perform that action at this time.
0 commit comments