Copilot commented on code in PR #16961:
URL: https://github.com/apache/iotdb/pull/16961#discussion_r2650372150


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java:
##########
@@ -1109,15 +1109,13 @@ public void deserialize(final InputStream inputStream) 
throws IOException {
       name = tableNode.getName();
       stack.push(new Pair<>(tableNode, false));
     } else {
-      // Currently internal mNode will not be the leaf node and thus will not 
be deserialized here
-      // This is just in case
       internalMNode = deserializeInternalMNode(inputStream);
       ReadWriteIOUtils.readInt(inputStream);
       name = internalMNode.getName();
       stack.push(new Pair<>(internalMNode, false));
     }
 
-    while (!PATH_ROOT.equals(name)) {
+    while (!PATH_ROOT.equals(name) || type != INTERNAL_MNODE_TYPE) {

Review Comment:
   The loop termination condition has a logical flaw. It will incorrectly stop 
when encountering any internal node named "root", not just the tree root. For 
example, if there's a path like "root.a.`root`.b.sg" where `root` is an escaped 
internal node name, the deserialization would terminate prematurely at that 
internal node.
   
   The condition should ensure we've reached the actual tree root, which is the 
last node serialized. One approach is to check if the stack has accumulated all 
the tree content, or use a different marker to identify the tree root 
specifically.
   ```suggestion
       while (stack.size() != 1 || !PATH_ROOT.equals(name) || type != 
INTERNAL_MNODE_TYPE) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to