Ctest created ZOOKEEPER-3721:
--------------------------------
Summary: Make the boolean configuration parameter only accept
"true" or "false"
Key: ZOOKEEPER-3721
URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3721
Project: ZooKeeper
Issue Type: Improvement
Components: server
Affects Versions: 3.5.6
Reporter: Ctest
*Description*
The QuorumPeerConfig.java uses java built-in method
{code:java}
Boolean.parseBoolean(String value){code}
to parse almost all boolean parameters. When the value is "true" (ignoring
case), this method will return true. Otherwise, it will return false. It means
all these boolean parameters can accept any string and translate it into false
as long as it is not "true".
standaloneEnabled and reconfigEnabled are two exceptions because they only
accept "true" or "false":
{code:java}
} else if (key.equals("standaloneEnabled")) {
if (value.toLowerCase().equals("true")) {
setStandaloneEnabled(true);
} else if (value.toLowerCase().equals("false")) {
setStandaloneEnabled(false);
} else {
throw new ConfigException("Invalid option "
+ value
+ " for standalone mode. Choose 'true' or
'false.'");
}{code}
*Improvement*
To improve this part, I am trying to unify all these boolean parser methods and
make them more robust. Generally, I wrote a parseBoolean which only accepts
"true" or "false" in QuorumPeerConfig.java and use this method for parsing all
boolean parameters.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)