is KmsMasterKeyProvider shareable

0

I checked the code of the class KmsMasterKeyProvider there are List<String>, so, I'm a bit unsure if this class can be shared among multiple threads, or if it's a good practice to share it in the first place. Could anyone help me? I'm using aws-encryption-sdk-java 2.4.1.

Thanks

asked 8 months ago200 views
1 Answer
0
Accepted Answer

Hi,

Have a look at the Javadoc: it states clearly that some methods are not thead safe.

See https://aws.github.io/aws-encryption-sdk-java/com/amazonaws/encryptionsdk/kms/KmsMasterKeyProvider.html#:~:text=Method%20Summary&text=This%20method%20is%20inherently%20not,the%20list%20of%20grant%20tokens.

This method is inherently not thread safe. Use withGrantTokens(List) or 
KmsMasterKey.setGrantTokens(List) instead. KmsMasterKeyProviders constructed using 
the builder will throw an exception on attempts to modify the list of grant tokens.

So, you should avoid this (deprecated) method to become thread safe.

Best,

Didier

profile pictureAWS
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions