HADOOP-18824. ZKDelegationTokenSecretManager causes ArithmeticException due to improper numRetries value checking (#6052)

This commit is contained in:
ConfX 2023-09-14 18:53:31 -04:00 committed by GitHub
parent dea446419f
commit 23360b3f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -222,7 +222,7 @@ public ZKDelegationTokenSecretManager(Configuration conf) {
ZK_DTSM_ZK_CONNECTION_TIMEOUT_DEFAULT)
)
.retryPolicy(
new RetryNTimes(numRetries, sessionT / numRetries));
new RetryNTimes(numRetries, numRetries == 0 ? 0 : sessionT / numRetries));
} catch (Exception ex) {
throw new RuntimeException("Could not Load ZK acls or auth: " + ex, ex);
}

View File

@ -106,10 +106,22 @@ protected Configuration getSecretConf(String connectString) {
@SuppressWarnings("unchecked")
@Test
public void testMultiNodeOperations() throws Exception {
testMultiNodeOperationsImpl(false);
}
@Test
public void testMultiNodeOperationsWithZeroRetry() throws Exception {
testMultiNodeOperationsImpl(true);
}
public void testMultiNodeOperationsImpl(boolean setZeroRetry) throws Exception {
for (int i = 0; i < TEST_RETRIES; i++) {
DelegationTokenManager tm1, tm2 = null;
String connectString = zkServer.getConnectString();
Configuration conf = getSecretConf(connectString);
if (setZeroRetry) {
conf.setInt(ZKDelegationTokenSecretManager.ZK_DTSM_ZK_NUM_RETRIES, 0);
}
tm1 = new DelegationTokenManager(conf, new Text("bla"));
tm1.init();
tm2 = new DelegationTokenManager(conf, new Text("bla"));