Repository navigation
Conversation
kezhuw
left a comment
There was a problem hiding this comment.
I think the problem resides in constructor of ZooKeeper. We should give clientConfig a no null ZKClientConfig there to not misuse it. But the change is good anyway.
zookeeper/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
Lines 1139 to 1147 in 777b372
| (sessionPasswd == null ? "<null>" : "<hidden>")); | ||
| } | ||
|
|
||
| ZKClientConfig clientConfig = options.getClientConfig(); |
There was a problem hiding this comment.
I would prefer to initialize clientConfig to non null here so we don't make mistake again.
There was a problem hiding this comment.
Done in 0ebc4a9: clientConfig is replaced with a new ZKClientConfig right where it is read from the options, so the rest of the constructor, including the HostProviderFactory call, only sees the non-null one.
anmolnar
left a comment
There was a problem hiding this comment.
lgtm. Please address remaining comment.
DnsSrvHostProviderreceives the client'sZKClientConfig, andZKClientConfigcopieszookeeper.hostProvider.dnsSrvRefreshIntervalSecondsfrom the system properties like the other client settings, but the refresh interval was read withLong.getLong(). A value set in a client config file or withZKClientConfig.setProperty()was ignored, so the provider kept refreshing every 60 seconds (or used whatever the system property said).The interval is now read from the given
ZKClientConfig, falling back to a newZKClientConfigwhen none is passed, the same wayHostConnectionManagerdoes. The system property keeps working becauseZKClientConfigis initialized from it.Behaviour changes, both limited to this new 3.10.0 provider:
NumberFormatException, consistent with how a negative value is rejected and howzookeeper.request.timeoutis handled.Testing
DnsSrvHostProviderTest#testRefreshIntervalFromClientConfig(interval1inZKClientConfig, expects a periodic lookup) and#testRefreshIntervalNegativeInClientConfig(-1inZKClientConfigis rejected) fail without the fix and pass with it. The existing system property tests still pass.org.apache.zookeeper.client.*Test,HostProviderSelectionTest,StaticHostProviderTest,ConnectStringParserTestandCustomHostProviderTestpass; checkstyle and spotbugs report no issues.new ZooKeeper("dns-srv://...", ..., new ZKClientConfig(configFile)), where the file sets the interval to 1, sent 1 SRV query during a 3.5 second session before the fix and 4 (one per second) after it.