Fix EmbeddedZkServerSuite embedded zookeeper server NPE problem
fixes #267 Squashed commit of the following: commit 38b3278e2bd4285dabeee093df855a1497ad35f8 Author: ulysses-you <ulyssesyou18@gmail.com> Date: Fri Jan 8 12:43:14 2021 +0800 user name commit 76c5691f4a9dc419668d8610f5cf148d266ff46c Author: cathy <cathy@cathydeMacBook-Pro.local> Date: Fri Jan 8 12:11:31 2021 +0800 move to stop commit 15e0ca8f7ec5e3fa27fda3572dc44ab3fa83c9ac Author: cathy <cathy@cathydeMacBook-Pro.local> Date: Fri Jan 8 11:50:49 2021 +0800 init
This commit is contained in:
parent
80f81b20ab
commit
7b56bb27f9
@ -58,6 +58,12 @@ class EmbeddedZkServer private(name: String) extends AbstractService(name) with
|
||||
|
||||
override def stop(): Unit = {
|
||||
if (server != null) {
|
||||
// Just a tradeoff, otherwise we may get NPE if we call stop() immediately.
|
||||
// (e.g. the unit test EmbeddedZkServerSuite)
|
||||
// TestingZooKeeperMain has a bug that the CountDownLatch released before cnxnFactory inited.
|
||||
// More details could see TestingZooKeeperMain.runFromConfig.
|
||||
while (getStartTime > 0 && System.currentTimeMillis() - getStartTime < 5000) {
|
||||
}
|
||||
server.close()
|
||||
server = null
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user