File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,9 @@ public void dropDatabase(final String dbName) {
469469 */
470470 public void close () {
471471 cluster .close ();
472- cursorCleaningService .shutdownNow ();
472+ if (cursorCleaningService != null ) {
473+ cursorCleaningService .shutdownNow ();
474+ }
473475 }
474476
475477 /**
Original file line number Diff line number Diff line change @@ -114,6 +114,12 @@ public void shouldSaveDefaultWriteConcern() throws UnknownHostException {
114114 }
115115 }
116116
117+ @ Test
118+ public void shouldCloseWithoutExceptionWhenCursorFinalizerIsDisabled () {
119+ Mongo mongo = new MongoClient (new ServerAddress (), MongoClientOptions .builder ().cursorFinalizerEnabled (false ).build ());
120+ mongo .close ();
121+ }
122+
117123 @ Test
118124 @ SuppressWarnings ("deprecation" ) // This is for testing the old API, so it will use deprecated methods
119125 public void shouldGetDB () throws UnknownHostException {
You can’t perform that action at this time.
0 commit comments