未验证 提交 91d3690a 编写于 作者: H HouliangQi 提交者: GitHub

[IOTDB-1414]NPE occurred when call getStorageGroupNodeByPath() method using not exist path

上级 a99bf9c7
......@@ -696,6 +696,9 @@ public class MTree implements Serializable {
}
MNode cur = root;
for (int i = 1; i < nodes.length; i++) {
if (cur == null) {
break;
}
cur = cur.getChild(nodes[i]);
if (cur instanceof StorageGroupMNode) {
return (StorageGroupMNode) cur;
......
......@@ -21,6 +21,7 @@ package org.apache.iotdb.db.metadata;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
import org.apache.iotdb.db.metadata.mnode.MNode;
import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
import org.apache.iotdb.db.metadata.template.Template;
......@@ -1562,4 +1563,38 @@ public class MManagerBasicTest {
fail(e.getMessage());
}
}
@Test
public void testGetStorageGroupNodeByPath() {
MManager manager = IoTDB.metaManager;
PartialPath partialPath = null;
try {
partialPath = new PartialPath("root.ln.sg1");
} catch (IllegalPathException e) {
fail(e.getMessage());
}
try {
manager.setStorageGroup(partialPath);
} catch (MetadataException e) {
fail(e.getMessage());
}
try {
partialPath = new PartialPath("root.ln.sg2.device1.sensor1");
} catch (IllegalPathException e) {
fail(e.getMessage());
}
try {
manager.getStorageGroupNodeByPath(partialPath);
} catch (StorageGroupNotSetException e) {
Assert.assertEquals(
"Storage group is not set for current seriesPath: [root.ln.sg2.device1.sensor1]",
e.getMessage());
} catch (MetadataException e) {
fail(e.getMessage());
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册