This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new e488a7c1bc2 [IOTDB-6164] Fix create illegal path through rest api bug 
(#11178)
e488a7c1bc2 is described below

commit e488a7c1bc242c617f7df3c9ff300155a1ed9ba3
Author: Jackie Tien <[email protected]>
AuthorDate: Tue Sep 19 11:44:43 2023 +0800

    [IOTDB-6164] Fix create illegal path through rest api bug (#11178)
---
 .../rest/v1/handler/StatementConstructionHandler.java    | 15 ++++++++++-----
 .../rest/v2/handler/StatementConstructionHandler.java    | 16 +++++++++++-----
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
index e8cbfe9c6aa..56846959556 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
@@ -17,7 +17,8 @@
 
 package org.apache.iotdb.db.protocol.rest.v1.handler;
 
-import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
 import org.apache.iotdb.db.protocol.rest.utils.InsertRowDataUtils;
 import org.apache.iotdb.db.protocol.rest.v1.model.InsertRecordsRequest;
@@ -42,14 +43,16 @@ public class StatementConstructionHandler {
 
   public static InsertTabletStatement constructInsertTabletStatement(
       InsertTabletRequest insertTabletRequest)
-      throws IllegalPathException, WriteProcessRejectException {
+      throws MetadataException, WriteProcessRejectException {
     TimestampPrecisionUtils.checkTimestampPrecision(
         
insertTabletRequest.getTimestamps().get(insertTabletRequest.getTimestamps().size()
 - 1));
     // construct insert statement
     InsertTabletStatement insertStatement = new InsertTabletStatement();
     insertStatement.setDevicePath(
         
DataNodeDevicePathCache.getInstance().getPartialPath(insertTabletRequest.getDeviceId()));
-    
insertStatement.setMeasurements(insertTabletRequest.getMeasurements().toArray(new
 String[0]));
+    insertStatement.setMeasurements(
+        
PathUtils.checkIsLegalSingleMeasurementsAndUpdate(insertTabletRequest.getMeasurements())
+            .toArray(new String[0]));
     List<List<Object>> rawData = insertTabletRequest.getValues();
     List<String> rawDataType = insertTabletRequest.getDataTypes();
 
@@ -176,7 +179,7 @@ public class StatementConstructionHandler {
 
   public static InsertRowsStatement createInsertRowsStatement(
       InsertRecordsRequest insertRecordsRequest)
-      throws IllegalPathException, IoTDBConnectionException {
+      throws MetadataException, IoTDBConnectionException {
 
     // construct insert statement
     InsertRowsStatement insertStatement = new InsertRowsStatement();
@@ -206,7 +209,9 @@ public class StatementConstructionHandler {
           DataNodeDevicePathCache.getInstance()
               .getPartialPath(insertRecordsRequest.getDeviceIds().get(i)));
       statement.setMeasurements(
-          insertRecordsRequest.getMeasurementsList().get(i).toArray(new 
String[0]));
+          PathUtils.checkIsLegalSingleMeasurementsAndUpdate(
+                  insertRecordsRequest.getMeasurementsList().get(i))
+              .toArray(new String[0]));
       
TimestampPrecisionUtils.checkTimestampPrecision(insertRecordsRequest.getTimestamps().get(i));
       statement.setTime(insertRecordsRequest.getTimestamps().get(i));
       statement.setDataTypes(dataTypesList.get(i).toArray(new TSDataType[0]));
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
index e6a993f8d5d..928f7d75329 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
@@ -17,7 +17,8 @@
 
 package org.apache.iotdb.db.protocol.rest.v2.handler;
 
-import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
 import org.apache.iotdb.db.protocol.rest.utils.InsertRowDataUtils;
 import org.apache.iotdb.db.protocol.rest.v2.model.InsertRecordsRequest;
@@ -42,14 +43,17 @@ public class StatementConstructionHandler {
 
   public static InsertTabletStatement constructInsertTabletStatement(
       InsertTabletRequest insertTabletRequest)
-      throws IllegalPathException, WriteProcessRejectException {
+      throws MetadataException, WriteProcessRejectException {
     TimestampPrecisionUtils.checkTimestampPrecision(
         
insertTabletRequest.getTimestamps().get(insertTabletRequest.getTimestamps().size()
 - 1));
     // construct insert statement
     InsertTabletStatement insertStatement = new InsertTabletStatement();
     insertStatement.setDevicePath(
         
DataNodeDevicePathCache.getInstance().getPartialPath(insertTabletRequest.getDevice()));
-    
insertStatement.setMeasurements(insertTabletRequest.getMeasurements().toArray(new
 String[0]));
+    // check whether measurement is legal according to syntax convention
+    insertStatement.setMeasurements(
+        
PathUtils.checkIsLegalSingleMeasurementsAndUpdate(insertTabletRequest.getMeasurements())
+            .toArray(new String[0]));
     List<List<Object>> rawData = insertTabletRequest.getValues();
     List<String> rawDataType = insertTabletRequest.getDataTypes();
 
@@ -176,7 +180,7 @@ public class StatementConstructionHandler {
 
   public static InsertRowsStatement createInsertRowsStatement(
       InsertRecordsRequest insertRecordsRequest)
-      throws IllegalPathException, IoTDBConnectionException {
+      throws MetadataException, IoTDBConnectionException {
 
     // construct insert statement
     InsertRowsStatement insertStatement = new InsertRowsStatement();
@@ -206,7 +210,9 @@ public class StatementConstructionHandler {
           DataNodeDevicePathCache.getInstance()
               .getPartialPath(insertRecordsRequest.getDevices().get(i)));
       statement.setMeasurements(
-          insertRecordsRequest.getMeasurementsList().get(i).toArray(new 
String[0]));
+          PathUtils.checkIsLegalSingleMeasurementsAndUpdate(
+                  insertRecordsRequest.getMeasurementsList().get(i))
+              .toArray(new String[0]));
       
TimestampPrecisionUtils.checkTimestampPrecision(insertRecordsRequest.getTimestamps().get(i));
       statement.setTime(insertRecordsRequest.getTimestamps().get(i));
       statement.setDataTypes(dataTypesList.get(i).toArray(new TSDataType[0]));

Reply via email to