@@ -60,19 +60,19 @@ protected void createCollection(String dbName, String collectionName) {
6060 protected void createCollectionNoDescription (String dbName , String collectionName ) {
6161 MongoClientOptions .Builder options = MongoClientOptions .builder ();
6262 configureMongoClientOptions (options );
63- try ( MongoClient client = new MongoClient (new ServerAddress (host , port ), options .build ())) {
64- client . getDatabase ( dbName ). createCollection ( collectionName );
65- }
63+ MongoDatabase db = new MongoClient (new ServerAddress (host , port ), options .build ()). getDatabase (
64+ dbName );
65+ db . createCollection ( collectionName );
6666 }
6767
6868 @ Override
6969 protected void createCollectionWithAlreadyBuiltClientOptions (
7070 String dbName , String collectionName ) {
7171 MongoClientOptions clientOptions = client .getMongoClientOptions ();
7272 MongoClientOptions newClientOptions = MongoClientOptions .builder (clientOptions ).build ();
73- try ( MongoClient client = new MongoClient (new ServerAddress (host , port ), newClientOptions )) {
74- client . getDatabase ( dbName ). createCollection ( collectionName );
75- }
73+ MongoDatabase db = new MongoClient (new ServerAddress (host , port ), newClientOptions ). getDatabase (
74+ dbName );
75+ db . createCollection ( collectionName );
7676 }
7777
7878 @ Override
@@ -81,9 +81,9 @@ protected void createCollectionCallingBuildTwice(String dbName, String collectio
8181 MongoClientOptions .builder ().description ("some-description" );
8282 configureMongoClientOptions (options );
8383 options .build ();
84- try ( MongoClient client = new MongoClient (new ServerAddress (host , port ), options .build ())) {
85- client . getDatabase ( dbName ). createCollection ( collectionName );
86- }
84+ MongoDatabase db = new MongoClient (new ServerAddress (host , port ), options .build ()). getDatabase (
85+ dbName );
86+ db . createCollection ( collectionName );
8787 }
8888
8989 @ Override
0 commit comments