A question about AWSKMS shutdown function
Describe the issue
The AWSKMS has this shutdown function: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kms/AWSKMS.html#shutdown-- which "Shuts down this client object, releasing any resources that might be held open". What resources are included? If I have a AWSKMS client built with STSAssumeRoleSessionCredentialsProvider which opens a background thread to refresh credentials, does the shutdown function in AWSKMS close this thread? Thanks!
Links
https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kms/AWSKMS.html#shutdown--
Hi @isaac33zhang, I'm sorry for taking so long to reply.
According to the STSAssumeRoleSessionCredentialsProvider Javadoc, when the credentials provider is no longer used the background thread can be shut down via the close() method, which closes its refreashableTask - https://github.com/aws/aws-sdk-java/blob/dbe095458104406605c081a13dc5aec734095ec9/aws-java-sdk-sts/src/main/java/com/amazonaws/auth/STSAssumeRoleSessionCredentialsProvider.java#L364-L371
After a very quick look at the Client shutdown code, I couldn't find anything that would close that refreshableTask. So I recommend to use STSAssumeRoleSessionCredentialsProvider#close if you want to be sure the thread is shutdown.
Hi @debora-ito Following up on your response, I have a couple questions:
- Could it be considered a potential AWS SDK issue that AwsKmsClient.close() doesn't properly close the refreshableTask?
- What's the recommended approach for managing AwsKmsClient instances in multi-threaded environments while ensuring all resources are properly closed? Does this mean we can't cache AwsKmsClient under any circumstances?
Would appreciate your insights.