Skip to content

Commit

Permalink
xx
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Dec 27, 2024
1 parent 3177994 commit 45db206
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ public Credential getCredential(String credentialType, CredentialContext context
return credentialCache.getCredential(credentialCacheKey, cacheKey -> doGetCredential(cacheKey));
}

// Get credential with only one credential provider.
public Credential getCredential(CredentialContext context) {
Preconditions.checkState(
credentialProviders.size() == 1, "Should only one credential provider");
if (credentialProviders.size() == 0) {
throw new RuntimeException("There are not any credential provider for the catalog.");
} else if (credentialProviders.size() > 1) {
throw new RuntimeException("There are multiple credential providers for the catalog.");
}
return getCredential(credentialProviders.keySet().iterator().next(), context);
}

Expand All @@ -73,6 +77,11 @@ public void close() {
e);
}
});
try {
credentialCache.close();
} catch (IOException e) {
LOG.warn("Close credential cache failed, catalog: {}", catalogName, e);
}
}

private Credential doGetCredential(CredentialCacheKey credentialCacheKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class CatalogWrapperForREST extends IcebergCatalogWrapper {

private final CatalogCredentialManager catalogCredentialManager;

private Map<String, String> catalogConfigToClients;
private final Map<String, String> catalogConfigToClients;

private static final Set<String> catalogPropertiesToClientKeys =
ImmutableSet.of(
Expand Down Expand Up @@ -131,7 +131,7 @@ private LoadTableResponse injectCredentialConfig(
.build();
}

@SuppressWarnings("Deperecated")
@SuppressWarnings("deprecation")
private Map<String, String> normalizeCredentialProperties(Map<String, String> properties) {
HashMap<String, String> normalizedProperties = new HashMap<>(properties);
String credentialProviderType = properties.get(CredentialConstants.CREDENTIAL_PROVIDER_TYPE);
Expand Down

0 comments on commit 45db206

Please sign in to comment.