Skip to content

Commit

Permalink
Fix AccessControlException while creating client configuration for Pe…
Browse files Browse the repository at this point in the history
…rsonalize client (#173) (#175)

### Description:
This change included fix AccessControlException while initialzing client configuration for AWS Personalize client.
We see below exception only when using credentials from opensearch keystore.
Exception message:
[ERROR][o.o.b.OpenSearchUncaughtExceptionHandler] [88665a0bfb08.ant.amazon.com] fatal error in thread [opensearch[88665a0bfb08.ant.amazon.com][management][T#2]], exiting
java.lang.ExceptionInInitializerError: null

Signed-off-by: Ketan Kulkarni <kektnr@amazon.com>
(cherry picked from commit e6fe9ed)

Co-authored-by: kulket <130191298+kulket@users.noreply.github.com>
  • Loading branch information
opensearch-trigger-bot[bot] and kulket authored Jul 18, 2023
1 parent 4bc0ea9 commit a8665f9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public class PersonalizeClient implements Closeable {
* @param awsRegion AWS region where Amazon Personalize campaign is hosted
*/
public PersonalizeClient(AWSCredentialsProvider credentialsProvider, String awsRegion) {
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withUserAgentPrefix(USER_AGENT_PREFIX);
ClientConfiguration clientConfiguration = AccessController.doPrivileged(
(PrivilegedAction<ClientConfiguration>) () -> new ClientConfiguration()
.withUserAgentPrefix(USER_AGENT_PREFIX));
personalizeRuntime = AccessController.doPrivileged(
(PrivilegedAction<AmazonPersonalizeRuntime>) () -> AmazonPersonalizeRuntimeClientBuilder.standard()
.withCredentials(credentialsProvider)
Expand Down

0 comments on commit a8665f9

Please sign in to comment.