From de814cba7a92226c339c858ab195727c78b56d4f Mon Sep 17 00:00:00 2001 From: albertshau Date: Wed, 1 Nov 2023 12:27:26 -0700 Subject: [PATCH] CDAP-20867 switch to cheaper secure store call in oauth handler Switch to use cheaper SecureStore.getData() call instead of SecureStore.get() when the secure key metadata is not needed --- .../cdap/internal/provision/ProvisionerMacroEvaluator.java | 2 +- .../main/java/io/cdap/cdap/datapipeline/oauth/OAuthStore.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/provision/ProvisionerMacroEvaluator.java b/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/provision/ProvisionerMacroEvaluator.java index 74838f66ed66..9eaa5ba72dba 100644 --- a/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/provision/ProvisionerMacroEvaluator.java +++ b/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/provision/ProvisionerMacroEvaluator.java @@ -54,7 +54,7 @@ public String evaluate(String macroFunction, String... arguments) throws Invalid throw new InvalidMacroException("Secure store macro function only supports 1 argument."); } try { - return Bytes.toString(secureStore.get(namespace, arguments[0]).get()); + return Bytes.toString(secureStore.getData(namespace, arguments[0])); } catch (Exception e) { throw new InvalidMacroException( "Failed to resolve macro '" + macroFunction + "(" + arguments[0] + ")'", e); diff --git a/cdap-app-templates/cdap-etl/cdap-data-pipeline-base/src/main/java/io/cdap/cdap/datapipeline/oauth/OAuthStore.java b/cdap-app-templates/cdap-etl/cdap-data-pipeline-base/src/main/java/io/cdap/cdap/datapipeline/oauth/OAuthStore.java index ede8ef3362df..7e4dcacf98f9 100644 --- a/cdap-app-templates/cdap-etl/cdap-data-pipeline-base/src/main/java/io/cdap/cdap/datapipeline/oauth/OAuthStore.java +++ b/cdap-app-templates/cdap-etl/cdap-data-pipeline-base/src/main/java/io/cdap/cdap/datapipeline/oauth/OAuthStore.java @@ -113,7 +113,7 @@ public Optional getProvider(String name) throws OAuthStoreExcepti OAuthClientCredentials clientCreds; try { String clientCredsJson = new String( - secureStore.get(NamespaceId.SYSTEM.getNamespace(), getClientCredsKey(name)).get(), + secureStore.getData(NamespaceId.SYSTEM.getNamespace(), getClientCredsKey(name)), StandardCharsets.UTF_8); clientCreds = GSON.fromJson(clientCredsJson, OAuthClientCredentials.class); } catch (IOException e) { @@ -171,7 +171,7 @@ public Optional getRefreshToken(String oauthProvider, String throws OAuthStoreException { try { String tokenJson = new String( - secureStore.get(NamespaceId.SYSTEM.getNamespace(), getRefreshTokenKey(oauthProvider, credentialId)).get(), + secureStore.getData(NamespaceId.SYSTEM.getNamespace(), getRefreshTokenKey(oauthProvider, credentialId)), StandardCharsets.UTF_8); return Optional.of(GSON.fromJson(tokenJson, OAuthRefreshToken.class)); } catch (IOException e) {