1919import com .mongodb .MongoClientException ;
2020import com .mongodb .MongoException ;
2121import com .mongodb .MongoInternalException ;
22+ import com .mongodb .assertions .Assertions ;
2223import com .mongodb .client .MongoClient ;
2324import com .mongodb .client .model .vault .DataKeyOptions ;
2425import com .mongodb .client .model .vault .EncryptOptions ;
4243import java .util .Map ;
4344import java .util .function .Supplier ;
4445
46+ import static com .mongodb .assertions .Assertions .assertNotNull ;
4547import static com .mongodb .assertions .Assertions .notNull ;
4648import static com .mongodb .crypt .capi .MongoCryptContext .State ;
4749
@@ -220,7 +222,7 @@ BsonValue decryptExplicitly(final BsonBinary value) {
220222 notNull ("value" , value );
221223
222224 try (MongoCryptContext decryptionContext = mongoCrypt .createExplicitDecryptionContext (new BsonDocument ("v" , value ))) {
223- return executeStateMachine (decryptionContext , null ).get ("v" );
225+ return assertNotNull ( executeStateMachine (decryptionContext , null ).get ("v" ) );
224226 } catch (MongoCryptException e ) {
225227 throw wrapInClientException (e );
226228 }
@@ -238,10 +240,6 @@ public void close() {
238240 }
239241 }
240242
241- public String getCryptSharedLibVersionString () {
242- return mongoCrypt .getCryptSharedLibVersionString ();
243- }
244-
245243 private RawBsonDocument executeStateMachine (final MongoCryptContext cryptContext , @ Nullable final String databaseName ) {
246244 while (true ) {
247245 State state = cryptContext .getState ();
@@ -275,7 +273,7 @@ private void fetchCredentials(final MongoCryptContext cryptContext) {
275273
276274 private void collInfo (final MongoCryptContext cryptContext , final String databaseName ) {
277275 try {
278- BsonDocument collectionInfo = collectionInfoRetriever .filter (databaseName , cryptContext .getMongoOperation ());
276+ BsonDocument collectionInfo = assertNotNull ( collectionInfoRetriever ) .filter (databaseName , cryptContext .getMongoOperation ());
279277 if (collectionInfo != null ) {
280278 cryptContext .addMongoOperationResult (collectionInfo );
281279 }
@@ -287,7 +285,7 @@ private void collInfo(final MongoCryptContext cryptContext, final String databas
287285
288286 private void mark (final MongoCryptContext cryptContext , final String databaseName ) {
289287 try {
290- RawBsonDocument markedCommand = commandMarker .mark (databaseName , cryptContext .getMongoOperation ());
288+ RawBsonDocument markedCommand = assertNotNull ( commandMarker ) .mark (databaseName , cryptContext .getMongoOperation ());
291289 cryptContext .addMongoOperationResult (markedCommand );
292290 cryptContext .completeMongoOperation ();
293291 } catch (Throwable t ) {
@@ -319,7 +317,7 @@ private void decryptKeys(final MongoCryptContext cryptContext) {
319317 }
320318 }
321319
322- private void decryptKey (final MongoKeyDecryptor keyDecryptor ) throws IOException {
320+ private void decryptKey (final MongoKeyDecryptor keyDecryptor ) {
323321 try (InputStream inputStream = keyManagementService .stream (keyDecryptor .getKmsProvider (), keyDecryptor .getHostName (),
324322 keyDecryptor .getMessage ())) {
325323 int bytesNeeded = keyDecryptor .bytesNeeded ();
0 commit comments