diff --git a/src/main/java/net/snowflake/ingest/connection/OAuthClient.java b/src/main/java/net/snowflake/ingest/connection/OAuthClient.java index 9f94912a5..bc2b64089 100644 --- a/src/main/java/net/snowflake/ingest/connection/OAuthClient.java +++ b/src/main/java/net/snowflake/ingest/connection/OAuthClient.java @@ -82,15 +82,14 @@ public void refreshToken() { if (respBody.has(ACCESS_TOKEN) && respBody.has(EXPIRES_IN)) { // Trim surrounding quotation marks String newAccessToken = respBody.get(ACCESS_TOKEN).toString().replaceAll("^\"|\"$", ""); - oAuthCredential.get().setAccessToken(newAccessToken); oAuthCredential.get().setExpiresIn(respBody.get(EXPIRES_IN).getAsInt()); - } else { - throw new SFException( - ErrorCode.OAUTH_REFRESH_TOKEN_ERROR, - "Refresh access token fail with response: " + respBodyString); + return; } } + throw new SFException( + ErrorCode.OAUTH_REFRESH_TOKEN_ERROR, + "Refresh access token fail with response: " + respBodyString); } catch (IOException e) { throw new SFException(ErrorCode.OAUTH_REFRESH_TOKEN_ERROR, e.getMessage()); } @@ -115,10 +114,7 @@ private HttpUriRequest makeRefreshTokenRequest() { payload.entrySet().stream() .map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.joining("&")); - - final StringEntity entity = - new StringEntity(payloadString, ContentType.APPLICATION_FORM_URLENCODED); - post.setEntity(entity); + post.setEntity(new StringEntity(payloadString, ContentType.APPLICATION_FORM_URLENCODED)); return post; }