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

已提問 8 個月前檢視次數 210 次
1 個回答
0
已接受的答案

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
專家
已回答 8 個月前
profile picture
專家
已審閱 8 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南