Skip to content

Commit

Permalink
Check for empty property
Browse files Browse the repository at this point in the history
  • Loading branch information
saxenapranav committed Dec 1, 2022
1 parent 2067fcb commit b7b2633
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public String getPasswordString(String key) throws IOException {
*/
private String getMandatoryPasswordString(String key) throws IOException {
String value = getPasswordString(key);
if (value == null) {
if (value == null || value.isEmpty()) {
throw new ConfigurationPropertyNotFoundException(key);
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ public void testConfigPropNotFound() throws Throwable {

for (String key : CONFIG_KEYS) {
setAuthConfig(abfsConf, true, AuthType.OAuth);
abfsConf.unset(key);
abfsConf.unset(key + "." + accountName);
testMissingConfigKey(abfsConf, key);
}
Expand All @@ -390,6 +391,24 @@ public void testConfigPropNotFound() throws Throwable {
unsetAuthConfig(abfsConf, true);
}

@Test
public void testConfigPropEmptyString() throws Throwable {
final String accountName = "account";

final Configuration conf = new Configuration();
final AbfsConfiguration abfsConf = new AbfsConfiguration(conf, accountName);

for (String key : CONFIG_KEYS) {
setAuthConfig(abfsConf, true, AuthType.OAuth);
abfsConf.set(key, "");
abfsConf.set(key + "." + accountName, "");
testMissingConfigKey(abfsConf, key);
}

unsetAuthConfig(abfsConf, false);
unsetAuthConfig(abfsConf, true);
}

private static void testMissingConfigKey(final AbfsConfiguration abfsConf,
final String confKey) throws Throwable {
GenericTestUtils.assertExceptionContains("Configuration property "
Expand Down

0 comments on commit b7b2633

Please sign in to comment.