Avoid NPEs when starting up and scanning brokers

The problem was we were trying to parse the JSON of /brokers/ids' when the
treecache found that node.

Fixes #8
This commit is contained in:
R. Tyler Croy 2015-01-26 06:20:46 -08:00
parent a022252157
commit 4f16c3dfd1
1 changed files with 7 additions and 1 deletions

View File

@ -68,9 +68,15 @@ class BrokerTreeWatcher implements TreeCacheListener {
}
ChildData nodeData = event.data
Integer brokerId = brokerIdFromPath(nodeData.path)
if (brokerId == INVALID_BROKER_ID) {
return
}
Object brokerData = json.parseText(new String(nodeData.data, 'UTF-8'))
this.brokers << new KafkaBroker(brokerData, brokerIdFromPath(nodeData.path))
this.brokers << new KafkaBroker(brokerData, brokerId)
}
/**