Not able to override WriteConcern.Majority config in mongodb-driver-sync-4.7.0.jar

We are using mongodb-driver-sync in our application. In clientEncryptionImpl.java writeConcern configuration was made hardcoded as Majority. We need to modify the writeConcern to 2 for a use case to test.

Please refer for code snippet

Hi Selva! Thanks for sharing and welcome to the Mongo developer forum!

The key vault collection’s read and write concerns are intentionally enforced to majority. This is to prevent rollbacks/data loss of encryption key material and follows the driver spec guidance: specifications/source/client-side-encryption/client-side-encryption.md at master · mongodb/specifications · GitHub.

That being said, could you share more details on the specific use case for changing these concerns? What are you trying to test?

Hi @Ajay_Tandon

Thanks for your reply.

Consider MongoDB is hosted in 5 nodes and two DCs. We are bringing down one DC completely and trying to write. Write Concern Majority expects 3 nodes ack where as we would have only 2 nodes ack. So we need to change writeConcern to 2.

@Ajay_Tandon

Any update on the above ask please.