[JAVA-3334] Wrong exception is thrown when mongocrypt_ctx_new fails Created: 26/Jun/19  Updated: 28/Oct/23  Resolved: 28/Jun/19

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 3.11.0

Type: Bug Priority: Minor - P4
Reporter: Shane Harvey Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Client-side FLE

 Description   

I think createDecryptionContext, createDataKeyContext, createExplicitEncryptionContext, and createExplicitDecryptionContext throw the wrong exception when mongocrypt_ctx_new fails:

        mongocrypt_ctx_t context = mongocrypt_ctx_new(wrapped);
        if (context == null) {
            MongoCryptContextImpl.throwExceptionFromStatus(context);
        }

https://github.com/mongodb/libmongocrypt/blob/1.0.0-beta2/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java#L153

Should be:

        mongocrypt_ctx_t context = mongocrypt_ctx_new(wrapped);
        if (context == null) {
            throwExceptionFromStatus();
        }



 Comments   
Comment by Githook User [ 28/Jun/19 ]

Author:

{'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}

Message: Java: Fix exceptions when there is no context

JAVA-3334
Branch: master
https://github.com/mongodb/libmongocrypt/commit/79c6686b1bb702344b1d2a1196b9c7729780f299

Comment by Ross Lawley [ 27/Jun/19 ]

PR: https://github.com/mongodb/libmongocrypt/pull/20

Comment by Ross Lawley [ 26/Jun/19 ]

Thanks shane.harvey - definitely looks wrong to me.

Generated at Thu Feb 08 08:59:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.