rdblue commented on code in PR #6489:
URL: https://github.com/apache/iceberg/pull/6489#discussion_r1072451113


##########
core/src/main/java/org/apache/iceberg/rest/auth/OAuth2Util.java:
##########
@@ -376,5 +450,201 @@ public Pair<Integer, TimeUnit> refresh(RESTClient client) 
{
 
       return null;
     }
+
+    private OAuthTokenResponse refreshCurrentToken(RESTClient client) {
+      if (isExpired(expiresAtMillis, System.currentTimeMillis())) {
+        // the token has already expired, attempt to refresh using the 
credential
+        return refreshExpiredToken(client);
+      } else {
+        // attempt a normal refresh
+        return refreshToken(client, headers(), token, tokenType, 
OAuth2Properties.CATALOG_SCOPE);
+      }
+    }
+
+    static boolean isExpired(Long expiresAtMillis, long now) {

Review Comment:
   The reason why I didn't add a method like this is that it isn't correct when 
`expiresAtMillis` is `null`. It returns false, but the token may still be 
expired. I think it's misleading to have a method with this name, so I think we 
should revert the change to add this.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to