-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: Close ZooKeeperClient if waitUntilConnected fails during construction #5411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
1b5d07c
cabce51
ec05c3e
227f889
40ddf9b
1a01f88
a19ff80
b6735f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,13 @@ class ZooKeeperClient(connectString: String, | |
| metricNames += "SessionState" | ||
|
|
||
| expiryScheduler.startup() | ||
| waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS) | ||
| try { | ||
| waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS) | ||
| } catch { | ||
| case e: ZooKeeperClientTimeoutException => | ||
| close() | ||
| throw e | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we don't need the block for try waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS)
catch {
case e: Throwable =>
close()
throw e
} |
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for updating, I still think we should use a finally block instead of catching a specific exception.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wait. I was wrong, we can't use finally here. But we should probably catch a more general exception?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can user ZooKeeperClientException, which parent is parent class for zk excpetions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, as other exceptions can be thrown too. But to be honest, we might as well catch
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the PR with |
||
| override def metricName(name: String, metricTags: scala.collection.Map[String, String]): MetricName = { | ||
| explicitMetricName(metricGroup, metricType, name, metricTags) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be a
finallyinstead ofcatch, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it some more, we actually need to shutdown the scheduler too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can call
ZooKeeperClient.close()?