Skip to content

Commit

Permalink
HADOOP-18824. ZKDelegationTokenSecretManager causes ArithmeticExcepti…
Browse files Browse the repository at this point in the history
…on due to improper numRetries value checking (apache#6052)
  • Loading branch information
teamconfx authored Sep 14, 2023
1 parent dea4464 commit 23360b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 23360b3

Please sign in to comment.