@@ -186,18 +186,22 @@ public static BsonDocument updateClientMedataDocument(final BsonDocument clientM
186186 BsonDocument updatedClientMetadataDocument = clientMetadataDocument .clone ();
187187 BsonDocument driverInformation = clientMetadataDocument .getDocument ("driver" );
188188
189- List <String > updatedDriverNames = new ArrayList <>();
190- List <String > updatedDriverVersions = new ArrayList <>();
191- List <String > updateDriverPlatforms = new ArrayList <>();
189+ List <String > driverNamesToAppend = mongoDriverInformation .getDriverNames ();
190+ List <String > driverVersionsToAppend = mongoDriverInformation .getDriverVersions ();
191+ List <String > driverPlatformsToAppend = mongoDriverInformation .getDriverPlatforms ();
192+
193+ List <String > updatedDriverNames = new ArrayList <>(driverNamesToAppend .size () + 1 );
194+ List <String > updatedDriverVersions = new ArrayList <>(driverVersionsToAppend .size () + 1 );
195+ List <String > updateDriverPlatforms = new ArrayList <>(driverPlatformsToAppend .size () + 1 );
192196
193197 updatedDriverNames .add (driverInformation .getString ("name" ).getValue ());
194- updatedDriverNames .addAll (mongoDriverInformation . getDriverNames () );
198+ updatedDriverNames .addAll (driverNamesToAppend );
195199
196200 updatedDriverVersions .add (driverInformation .getString ("version" ).getValue ());
197- updatedDriverVersions .addAll (mongoDriverInformation . getDriverVersions () );
201+ updatedDriverVersions .addAll (driverVersionsToAppend );
198202
199203 updateDriverPlatforms .add (clientMetadataDocument .getString ("platform" ).getValue ());
200- updateDriverPlatforms .addAll (mongoDriverInformation . getDriverPlatforms () );
204+ updateDriverPlatforms .addAll (driverPlatformsToAppend );
201205
202206 tryWithLimit (updatedClientMetadataDocument , d -> {
203207 putAtPath (d , "driver.name" , listToString (updatedDriverNames ));
0 commit comments