adutra commented on code in PR #10753: URL: https://github.com/apache/iceberg/pull/10753#discussion_r1809236938
########## core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java: ########## @@ -273,35 +227,11 @@ public void initialize(String name, Map<String, String> unresolved) { this.endpoints = ImmutableSet.copyOf(config.endpoints()); } - this.sessions = newSessionCache(mergedProps); - this.tableSessions = newSessionCache(mergedProps); - this.keepTokenRefreshed = - PropertyUtil.propertyAsBoolean( - mergedProps, - OAuth2Properties.TOKEN_REFRESH_ENABLED, - OAuth2Properties.TOKEN_REFRESH_ENABLED_DEFAULT); this.client = clientBuilder.apply(mergedProps); this.paths = ResourcePaths.forCatalogProperties(mergedProps); - String token = mergedProps.get(OAuth2Properties.TOKEN); - this.catalogAuth = - new AuthSession( - baseHeaders, - AuthConfig.builder() - .credential(credential) - .scope(scope) - .oauth2ServerUri(oauth2ServerUri) - .optionalOAuthParams(optionalOAuthParams) - .build()); - if (authResponse != null) { - this.catalogAuth = - AuthSession.fromTokenResponse( - client, tokenRefreshExecutor(name), authResponse, startTimeMillis, catalogAuth); - } else if (token != null) { - this.catalogAuth = - AuthSession.fromAccessToken( - client, tokenRefreshExecutor(name), token, expiresAtMillis(mergedProps), catalogAuth); - } + authManager.initialize(name, client, mergedProps); Review Comment: OK, I was able to improve things a bit. I'm not using two instances because I think it's important to reuse the authentication data obtained from the interaction with the config endpoint; but, I removed the double initialization, that indeed felt a bit awkward. I also removed the double call to the same `catalogSession` method; there is now a separate `preConfigSession` method that is meant to return a temporary, short-lived session for contacting the config endpoint only. This is in commit 4abc8dc. Let me know what you think! -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org