prevent NullPointerException if znode contains no data. TODO comment about possible race conditions due to method TreeCache.process(..) is asynchronous

This commit is contained in:
Alfredo Diaz
2015-05-17 01:29:28 +02:00
parent 1a0938866e
commit e98c2dbb36

View File

@@ -42,6 +42,11 @@ public class ZookeeperPropertySource extends EnumerablePropertySource<CuratorFra
cache = TreeCache.newBuilder(source, context).build();
cache.start();
running = true;
/*
TODO: race condition since TreeCache.process(..) is invoked asynchronously.
Methods getProperty and getPropertyNames could be invoked before that TreeCache.process(..) receives
all the WatchedEvents.
*/
}
catch (NoNodeException e) {
// no node, ignore
@@ -74,7 +79,7 @@ public class ZookeeperPropertySource extends EnumerablePropertySource<CuratorFra
return;
for (Map.Entry<String, ChildData> entry : children.entrySet()) {
ChildData child = entry.getValue();
if (child.getData().length == 0) {
if (child.getData()==null || child.getData().length == 0) {
findKeys(keys, child.getPath());
}
else {