[
https://issues.apache.org/jira/browse/HADOOP-18824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17763702#comment-17763702
]
ASF GitHub Bot commented on HADOOP-18824:
-----------------------------------------
teamconfx opened a new pull request, #6052:
URL: https://github.com/apache/hadoop/pull/6052
### Description of PR
https://issues.apache.org/jira/browse/HADOOP-18824
This PR hardcoded the sleeping time between retry to 0 when the retry time
is 0 to avoid division by zero.
### How was this patch tested?
1. set `zk-dt-secret-manager.zkNumRetries=0`
2. run
`org.apache.hadoop.security.token.delegation.TestZKDelegationTokenSecretManager.testMultiNodeOperations`
The test passes rather than throwing division by zero.
### For code changes:
- [x] Does the title or this PR starts with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the
endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
> ZKDelegationTokenSecretManager causes ArithmeticException due to improper
> numRetries value checking
> ---------------------------------------------------------------------------------------------------
>
> Key: HADOOP-18824
> URL: https://issues.apache.org/jira/browse/HADOOP-18824
> Project: Hadoop Common
> Issue Type: Bug
> Reporter: ConfX
> Priority: Critical
> Attachments: reproduce.sh
>
>
> h2. What happened
> There is no value checking for parameter
> {{{}zk-dt-secret-manager.zkNumRetries{}}}. This may cause improper
> calculations and crashes the system like division by 0.
> h2. Buggy code
> In {{{}ZKDelegationTokenSecretManager.java{}}}, there is no value checking
> for {{numRetries}} which is passed directly in {{RetryNTimes}} constructor.
> When {{numRetries}} is mistakenly set to 0, the code would cause division by
> 0 and throw ArithmeticException to crash the system.
> {noformat}
> public ZKDelegationTokenSecretManager(Configuration conf) {
> ...
> int numRetries =
> conf.getInt(ZK_DTSM_ZK_NUM_RETRIES,
> ZK_DTSM_ZK_NUM_RETRIES_DEFAULT);
> builder =
> ...
> .retryPolicy(
> new RetryNTimes(numRetries, sessionT / numRetries));
> ...{noformat}
> h2. How to reproduce
> # set zk-dt-secret-manager.zkNumRetries=0
> # run
> org.apache.hadoop.security.token.delegation.TestZKDelegationTokenSecretManager.testMultiNodeOperations
> # You will see the following stack trace.
> {noformat}
> java.lang.RuntimeException: Could not Load ZK acls or auth:
> java.lang.ArithmeticException: / by zero
> at
> org.apache.hadoop.security.token.delegation.ZKDelegationTokenSecretManager.<init>(ZKDelegationTokenSecretManager.java:227)
> at
> org.apache.hadoop.security.token.delegation.web.DelegationTokenManager$ZKSecretManager.<init>(DelegationTokenManager.java:99)
> at
> org.apache.hadoop.security.token.delegation.web.DelegationTokenManager.<init>(DelegationTokenManager.java:120)
> at
> org.apache.hadoop.security.token.delegation.TestZKDelegationTokenSecretManager.testMultiNodeOperations(TestZKDelegationTokenSecretManager.java:113)
> ...{noformat}
> For an easy reproduction, run the reproduce.sh in the attachment. We are
> happy to provide a patch if this issue is confirmed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]