danielcweeks commented on code in PR #12197: URL: https://github.com/apache/iceberg/pull/12197#discussion_r1978340592
########## aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java: ########## @@ -138,148 +133,42 @@ boolean keepTokenRefreshed() { OAuth2Properties.TOKEN_REFRESH_ENABLED_DEFAULT); } - @VisibleForTesting - ScheduledExecutorService tokenRefreshExecutor() { - if (!keepTokenRefreshed()) { - return null; - } - - if (null == tokenRefreshExecutor) { - synchronized (S3V4RestSignerClient.class) { - if (null == tokenRefreshExecutor) { - tokenRefreshExecutor = ThreadPools.newScheduledPool("s3-signer-token-refresh", 1); - } - } - } - - return tokenRefreshExecutor; - } - - private Cache<String, AuthSession> authSessionCache() { - if (null == authSessionCache) { - synchronized (S3V4RestSignerClient.class) { - if (null == authSessionCache) { - long expirationIntervalMs = - PropertyUtil.propertyAsLong( - properties(), - CatalogProperties.AUTH_SESSION_TIMEOUT_MS, - CatalogProperties.AUTH_SESSION_TIMEOUT_MS_DEFAULT); - - authSessionCache = - Caffeine.newBuilder() - .expireAfterAccess(Duration.ofMillis(expirationIntervalMs)) - .removalListener( - (RemovalListener<String, AuthSession>) - (id, auth, cause) -> { - if (null != auth) { - LOG.trace("Stopping refresh for AuthSession"); - auth.stopRefreshing(); - } - }) - .build(); - } - } - } - - return authSessionCache; - } - private RESTClient httpClient() { if (null == httpClient) { synchronized (S3V4RestSignerClient.class) { if (null == httpClient) { - httpClient = + authManager = AuthManagers.loadAuthManager("s3-signer", properties()); + HTTPClient client = HTTPClient.builder(properties()) .uri(baseSignerUri()) .withObjectMapper(S3ObjectMapper.mapper()) .build(); + ImmutableMap.Builder<String, String> properties = + ImmutableMap.<String, String>builder() + .putAll(properties()) + .putAll(optionalOAuthParams()) + .put(OAuth2Properties.OAUTH2_SERVER_URI, oauth2ServerUri()) + .put(OAuth2Properties.TOKEN_REFRESH_ENABLED, String.valueOf(keepTokenRefreshed())) + .put(OAuth2Properties.SCOPE, SCOPE); + String token = token().get(); + if (null != token) { + properties.put(OAuth2Properties.TOKEN, token); + } else if (credentialProvided()) { + properties.put(OAuth2Properties.CREDENTIAL, credential()); + } + authSession = authManager.catalogSession(client, properties.buildKeepingLast()); Review Comment: Shouldn't this be a `tableSession`? -- 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