pandeysambhi commented on code in PR #8116:
URL: https://github.com/apache/gravitino/pull/8116#discussion_r2281229328


##########
clients/client-java/src/main/java/org/apache/gravitino/client/DefaultOAuth2TokenProvider.java:
##########
@@ -35,18 +35,21 @@ private DefaultOAuth2TokenProvider() {}
   @Override
   protected String getAccessToken() {
     synchronized (this) {
-      Long expires = OAuth2ClientUtil.expiresAtMillis(token);
-      if (expires == null) {
-        return null;
+      if (token == null) {
+        token =
+            OAuth2ClientUtil.fetchToken(client, Collections.emptyMap(), 
credential, scope, path)
+                .getAccessToken();
+        return token;
       }
 
-      if (expires > System.currentTimeMillis()) {
+      Long expires = OAuth2ClientUtil.expiresAtMillis(token);
+      if (expires == null || expires <= System.currentTimeMillis()) {
+        token =
+            OAuth2ClientUtil.fetchToken(client, Collections.emptyMap(), 
credential, scope, path)
+                .getAccessToken();
         return token;
       }
 
-      token =
-          OAuth2ClientUtil.fetchToken(client, Collections.emptyMap(), 
credential, scope, path)
-              .getAccessToken();
       return token;

Review Comment:
   As I had multiple ifs, so had the return statements to return as soon as any 
condition was fulfilled, after incorporating @jerqi 's suggestions, I updated 
to have only one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to