|
@@ -458,7 +458,7 @@ public class DataTree {
|
|
|
}
|
|
|
synchronized (parent) {
|
|
|
Set<String> children = parent.getChildren();
|
|
|
- if (children != null && children.contains(childName)) {
|
|
|
+ if (children.contains(childName)) {
|
|
|
throw new KeeperException.NodeExistsException();
|
|
|
}
|
|
|
|
|
@@ -677,13 +677,7 @@ public class DataTree {
|
|
|
if (stat != null) {
|
|
|
n.copyStat(stat);
|
|
|
}
|
|
|
- ArrayList<String> children;
|
|
|
- Set<String> childs = n.getChildren();
|
|
|
- if (childs == null) {
|
|
|
- children = new ArrayList<String>(0);
|
|
|
- } else {
|
|
|
- children = new ArrayList<String>(childs);
|
|
|
- }
|
|
|
+ List<String> children=new ArrayList<String>(n.getChildren());
|
|
|
|
|
|
if (watcher != null) {
|
|
|
childWatches.addWatch(path, watcher);
|
|
@@ -1056,17 +1050,12 @@ public class DataTree {
|
|
|
int len = 0;
|
|
|
synchronized (node) {
|
|
|
Set<String> childs = node.getChildren();
|
|
|
- if (childs != null) {
|
|
|
- children = childs.toArray(new String[childs.size()]);
|
|
|
- }
|
|
|
+ children = childs.toArray(new String[childs.size()]);
|
|
|
len = (node.data == null ? 0 : node.data.length);
|
|
|
}
|
|
|
// add itself
|
|
|
counts.count += 1;
|
|
|
counts.bytes += len;
|
|
|
- if (children == null || children.length == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
for (String child : children) {
|
|
|
getCounts(path + "/" + child, counts);
|
|
|
}
|
|
@@ -1106,11 +1095,9 @@ public class DataTree {
|
|
|
String children[] = null;
|
|
|
synchronized (node) {
|
|
|
Set<String> childs = node.getChildren();
|
|
|
- if (childs != null) {
|
|
|
- children = childs.toArray(new String[childs.size()]);
|
|
|
- }
|
|
|
+ children = childs.toArray(new String[childs.size()]);
|
|
|
}
|
|
|
- if (children == null || children.length == 0) {
|
|
|
+ if (children.length == 0) {
|
|
|
// this node does not have a child
|
|
|
// is the leaf node
|
|
|
// check if its the leaf node
|
|
@@ -1169,23 +1156,19 @@ public class DataTree {
|
|
|
//are never changed
|
|
|
nodeCopy = new DataNode(node.data, node.acl, statCopy);
|
|
|
Set<String> childs = node.getChildren();
|
|
|
- if (childs != null) {
|
|
|
- children = childs.toArray(new String[childs.size()]);
|
|
|
- }
|
|
|
+ children = childs.toArray(new String[childs.size()]);
|
|
|
}
|
|
|
oa.writeString(pathString, "path");
|
|
|
oa.writeRecord(nodeCopy, "node");
|
|
|
path.append('/');
|
|
|
int off = path.length();
|
|
|
- if (children != null) {
|
|
|
- for (String child : children) {
|
|
|
- // since this is single buffer being resused
|
|
|
- // we need
|
|
|
- // to truncate the previous bytes of string.
|
|
|
- path.delete(off, Integer.MAX_VALUE);
|
|
|
- path.append(child);
|
|
|
- serializeNode(oa, path);
|
|
|
- }
|
|
|
+ for (String child : children) {
|
|
|
+ // since this is single buffer being resused
|
|
|
+ // we need
|
|
|
+ // to truncate the previous bytes of string.
|
|
|
+ path.delete(off, Integer.MAX_VALUE);
|
|
|
+ path.append(child);
|
|
|
+ serializeNode(oa, path);
|
|
|
}
|
|
|
}
|
|
|
|