From 89c5cf04bd97674d4750843d041324b93a66b892 Mon Sep 17 00:00:00 2001 From: Mauro Mugnaini Date: Thu, 13 Jul 2023 13:06:24 +0200 Subject: [PATCH] Revised code to avoid method invoked twice and double logging --- .../org/gcube/common/keycloak/DefaultKeycloakClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/common/keycloak/DefaultKeycloakClient.java b/src/main/java/org/gcube/common/keycloak/DefaultKeycloakClient.java index 6ff9a44..3a9c8e7 100644 --- a/src/main/java/org/gcube/common/keycloak/DefaultKeycloakClient.java +++ b/src/main/java/org/gcube/common/keycloak/DefaultKeycloakClient.java @@ -299,8 +299,9 @@ public class DefaultKeycloakClient implements KeycloakClient { params.put(GRANT_TYPE_PARAMETER, Arrays.asList(UMA_TOKEN_GRANT_TYPE)); try { - params.put(AUDIENCE_PARAMETER, Arrays.asList(URLEncoder.encode(checkAudience(audience), "UTF-8"))); - logger.trace("audience is {}", checkAudience(audience)); + String audienceToSend = URLEncoder.encode(checkAudience(audience), "UTF-8"); + params.put(AUDIENCE_PARAMETER, Arrays.asList(audienceToSend)); + logger.trace("audience is {}", audienceToSend); } catch (UnsupportedEncodingException e) { logger.error("Can't URL encode audience: {}", audience, e); }