[JAVA-4993] MongoClient leak where AutoEncryptionSettings#keyVaultMongoClientSettings is non-null and AutoEncryptionSettings#isBypassAutoEncryption is false Created: 30/May/23  Updated: 28/Oct/23  Resolved: 12/Jun/23

Status: Closed
Project: Java Driver
Component/s: Client Side Encryption
Affects Version/s: None
Fix Version/s: 4.10.0

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Looks like in com.mongodb.client.internal.Crypts#createCrypt, and possibly the reactive version of that method, leaks a MongoClient in the case where AutoEncryptionSettings#keyVaultMongoClientSettings is non-null and AutoEncryptionSettings#isBypassAutoEncryption is false.  In this case, two MongoClient instances are created (it's not clear why), and only internalClient is closed by com.mongodb.client.internal.Crypt



 Comments   
Comment by Githook User [ 12/Jun/23 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Fix MongoClient leak in auto-encryption (#1142)

When AutoEncryptionSettings#keyVaultMongoClientSettings is non-null and
AutoEncryptionSettings#isBypassAutoEncryption is false, the second internal
MongoClient is now closed when the containing MongoClient is closed.

The bug is fixed in both the synchronous and reactive streams drivers.

JAVA-4993
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6332c1409535cc8e7681f7aa5560863c37076203

Comment by Jeffrey Yemin [ 30/May/23 ]

Confirmed via manual testing with tour.ClientSideEncryptionAutoEncryptionSettingsTour that there is indeed a MongoClient leak.

Generated at Thu Feb 08 09:03:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.