You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/05/21 15:26:38 UTC
[GitHub] [hadoop] sadikovi commented on a change in pull request #3041: HADOOP-17725. Improve error message for token providers in ABFS
sadikovi commented on a change in pull request #3041:
URL: https://github.com/apache/hadoop/pull/3041#discussion_r637006602
##########
File path: hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/TestAccountConfiguration.java
##########
@@ -361,6 +366,56 @@ public void testAccessTokenProviderPrecedence()
testGlobalAndAccountOAuthPrecedence(abfsConf, null, AuthType.OAuth);
}
+ @Test
+ public void testConfigPropNotFound() throws Exception {
+ final String accountName = "account";
+
+ final Configuration conf = new Configuration();
+ final AbfsConfiguration abfsConf = new AbfsConfiguration(conf, accountName);
+
+ setAuthConfig(abfsConf, true, AuthType.OAuth);
+ abfsConf.unset(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ENDPOINT + "." + accountName);
Review comment:
Hmm... Can you create some kind of for loop to iterate over the keys, otherwise, the code is duplicated quite a bit. I would also suggest creating separate tests for each.
##########
File path: hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/ClientCredsTokenProvider.java
##########
@@ -38,19 +42,27 @@
private static final Logger LOG = LoggerFactory.getLogger(AccessTokenProvider.class);
-
public ClientCredsTokenProvider(final String authEndpoint,
- final String clientId, final String clientSecret) {
-
- Preconditions.checkNotNull(authEndpoint, "authEndpoint");
- Preconditions.checkNotNull(clientId, "clientId");
- Preconditions.checkNotNull(clientSecret, "clientSecret");
+ final String clientId, final String clientSecret)
+ throws AzureBlobFileSystemException {
+ validateClientCredsTokenProvider(
Review comment:
That is not going to work. You probably want to keep non-null check here, since this class does not depend on Hadoop configuration.
##########
File path: hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/ClientCredsTokenProvider.java
##########
@@ -38,19 +42,27 @@
private static final Logger LOG = LoggerFactory.getLogger(AccessTokenProvider.class);
-
public ClientCredsTokenProvider(final String authEndpoint,
- final String clientId, final String clientSecret) {
-
- Preconditions.checkNotNull(authEndpoint, "authEndpoint");
- Preconditions.checkNotNull(clientId, "clientId");
- Preconditions.checkNotNull(clientSecret, "clientSecret");
+ final String clientId, final String clientSecret)
+ throws AzureBlobFileSystemException {
+ validateClientCredsTokenProvider(
+ ConfigurationKeys.FS_AZURE_ACCOUNT_OAUTH_CLIENT_ENDPOINT, authEndpoint);
+ validateClientCredsTokenProvider(
+ ConfigurationKeys.FS_AZURE_ACCOUNT_OAUTH_CLIENT_ID, clientId);
+ validateClientCredsTokenProvider(
+ ConfigurationKeys.FS_AZURE_ACCOUNT_OAUTH_CLIENT_SECRET, clientSecret);
this.authEndpoint = authEndpoint;
this.clientId = clientId;
this.clientSecret = clientSecret;
}
+ private void validateClientCredsTokenProvider(final String configName,
Review comment:
IMHO, it is better to move it to AbfsConfiguration.java. It will allow you to cover other token providers there as well.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org