apache/hadoop · error · RuntimeException
Node {key} contains children of its own.
Error message
Node {key} contains children of its own. What it means
removeChildStr(key) removes a child from the current Node and returns its text value, but first asserts the node has no children of its own (OfflineImageReconstructor.java:287). This RuntimeException (not IOException) fires when the XML maps a scalar field onto an element that contains nested elements - the value of <key> is structured where the fsimage schema demands a plain number or string.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java:287
}
LinkedList<Node> cur = children.get(key);
if (cur == null) {
return null;
}
Node node = cur.remove();
if ((node == null) || cur.isEmpty()) {
children.remove(key);
}
return node;
}
String removeChildStr(String key) {
Node child = removeChild(key);
if (child == null) {
return null;
}
if ((child.children != null) && (!child.children.isEmpty())) {
throw new RuntimeException("Node " + key + " contains children " +
"of its own.");
}
return child.getVal();
}
Integer removeChildInt(String key) throws IOException {
String str = removeChildStr(key);
if (str == null) {
return null;
}
return Integer.valueOf(str);
}
Long removeChildLong(String key) throws IOException {
String str = removeChildStr(key);
if (str == null) {
return null;
}View on GitHub (pinned to 2add963021)
Solutions
- Flatten the element so its content is a single text value
- If the nested structure carries real fields, re-express them as correctly named sibling elements the processor understands
- Regenerate the XML from the original fsimage and redo the edit structurally
Example fix
<!-- before: scalar field wrapped in child elements --> <replication><desired>3</desired></replication> <!-- after --> <replication>3</replication>
Defensive patterns
Strategy: type-guard
Type guard
// Guard: only treat an element as a scalar value when it is a leaf
static boolean isLeafElement(org.w3c.dom.Node n) {
NodeList children = n.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (children.item(i).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
return false;
}
}
return true;
}
// use before reading any scalar field in pre-flight validation:
NodeList scalars = xpath.evaluate("//replication", doc, XPathConstants.NODESET);
for (int i = 0; i < scalars.getLength(); i++) {
if (!isLeafElement(scalars.item(i))) {
throw new IllegalArgumentException(
scalars.item(i).getNodeName() + " must contain text, not child elements");
}
} Prevention
- Keep scalar fields as plain text - never wrap values in child elements
- When a field needs structure, express it as the named sibling elements oiv emits
- Run a leaf-check over scalar fields as a pre-flight step after transforms
When it happens
Trigger: Any SectionProcessor reading a scalar field such as <replication>, <nsQuota>, <numBytes>, or <namespaceId> whose element wraps child elements instead of text - e.g. <replication><desired>3</desired></replication> - typically from hand edits or transforms that 'type-annotate' values.
Common situations: Wrapping values to attach metadata (<id><long>16386</long></id>); XML produced by exporters that model every value as a tree.
Related errors
- Expecting {expected}, but got XMLStreamException
- Got unexpected attribute: {ev}
- Got unxpected characters while looking for {expected}: {ev.a
- Got unexpected end event while looking for {expected}
- Failed to find <{expected}>; got {ev.asStartElement().getNam
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/2b5d96dbda340e3c.
Report an issue: GitHub.