19
19
import com .mongodb .MongoClientException ;
20
20
import com .mongodb .MongoException ;
21
21
import com .mongodb .MongoInternalException ;
22
+ import com .mongodb .assertions .Assertions ;
22
23
import com .mongodb .client .MongoClient ;
23
24
import com .mongodb .client .model .vault .DataKeyOptions ;
24
25
import com .mongodb .client .model .vault .EncryptOptions ;
42
43
import java .util .Map ;
43
44
import java .util .function .Supplier ;
44
45
46
+ import static com .mongodb .assertions .Assertions .assertNotNull ;
45
47
import static com .mongodb .assertions .Assertions .notNull ;
46
48
import static com .mongodb .crypt .capi .MongoCryptContext .State ;
47
49
@@ -220,7 +222,7 @@ BsonValue decryptExplicitly(final BsonBinary value) {
220
222
notNull ("value" , value );
221
223
222
224
try (MongoCryptContext decryptionContext = mongoCrypt .createExplicitDecryptionContext (new BsonDocument ("v" , value ))) {
223
- return executeStateMachine (decryptionContext , null ).get ("v" );
225
+ return assertNotNull ( executeStateMachine (decryptionContext , null ).get ("v" ) );
224
226
} catch (MongoCryptException e ) {
225
227
throw wrapInClientException (e );
226
228
}
@@ -238,10 +240,6 @@ public void close() {
238
240
}
239
241
}
240
242
241
- public String getCryptSharedLibVersionString () {
242
- return mongoCrypt .getCryptSharedLibVersionString ();
243
- }
244
-
245
243
private RawBsonDocument executeStateMachine (final MongoCryptContext cryptContext , @ Nullable final String databaseName ) {
246
244
while (true ) {
247
245
State state = cryptContext .getState ();
@@ -275,7 +273,7 @@ private void fetchCredentials(final MongoCryptContext cryptContext) {
275
273
276
274
private void collInfo (final MongoCryptContext cryptContext , final String databaseName ) {
277
275
try {
278
- BsonDocument collectionInfo = collectionInfoRetriever .filter (databaseName , cryptContext .getMongoOperation ());
276
+ BsonDocument collectionInfo = assertNotNull ( collectionInfoRetriever ) .filter (databaseName , cryptContext .getMongoOperation ());
279
277
if (collectionInfo != null ) {
280
278
cryptContext .addMongoOperationResult (collectionInfo );
281
279
}
@@ -287,7 +285,7 @@ private void collInfo(final MongoCryptContext cryptContext, final String databas
287
285
288
286
private void mark (final MongoCryptContext cryptContext , final String databaseName ) {
289
287
try {
290
- RawBsonDocument markedCommand = commandMarker .mark (databaseName , cryptContext .getMongoOperation ());
288
+ RawBsonDocument markedCommand = assertNotNull ( commandMarker ) .mark (databaseName , cryptContext .getMongoOperation ());
291
289
cryptContext .addMongoOperationResult (markedCommand );
292
290
cryptContext .completeMongoOperation ();
293
291
} catch (Throwable t ) {
@@ -319,7 +317,7 @@ private void decryptKeys(final MongoCryptContext cryptContext) {
319
317
}
320
318
}
321
319
322
- private void decryptKey (final MongoKeyDecryptor keyDecryptor ) throws IOException {
320
+ private void decryptKey (final MongoKeyDecryptor keyDecryptor ) {
323
321
try (InputStream inputStream = keyManagementService .stream (keyDecryptor .getKmsProvider (), keyDecryptor .getHostName (),
324
322
keyDecryptor .getMessage ())) {
325
323
int bytesNeeded = keyDecryptor .bytesNeeded ();
0 commit comments