File tree 1 file changed +16
-3
lines changed
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 {
291
291
_socket .setSoTimeout ( _options .socketTimeout );
292
292
_in = new BufferedInputStream ( _socket .getInputStream () );
293
293
_out = _socket .getOutputStream ();
294
- if (mongo != null ) {
295
- _serverVersion = getVersion (runCommand (mongo .getDB ("admin" ), new BasicDBObject ("buildinfo" , 1 )));
296
- }
297
294
successfullyConnected = true ;
298
295
}
299
296
catch ( IOException e ){
@@ -316,6 +313,22 @@ private synchronized void ensureOpen(final Mongo mongo) throws IOException {
316
313
sleepTime *= 2 ;
317
314
}
318
315
} 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
+ }
319
332
}
320
333
321
334
@ SuppressWarnings ("unchecked" )
You can’t perform that action at this time.
0 commit comments